-
-
Notifications
You must be signed in to change notification settings - Fork 21k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subtract blend mode produces different results with different renderers #77448
Comments
This is likely a result of the OpenGL renderer being based on the Godot 3 renderer and may just be an oversight. @clayjohn whats your take on this? |
I think the Vulkan renderer mistakenly uses I.e. if you want to write a white pixel to a grey background with To illustrate, here is a simple example with a white background and a middle grey square on top. In Vulkan the white background is subtracted from the grey resulting in all black where they intersect In OpenGL the grey is subtracted from the white so the final result is still grey |
Given that the Subtract blend mode in Godot has historically (pre-4.0) mapped to I think it would be good to know if there was a deliberate choice and use case that prompted the change in subtract blend mode behaviour. If there wasn’t, then it would make most sense to change the new 4.0 renderers to |
After reading @clayjohn's comments about what he would expect for the behaviour of a "subtract" blend mode, I became curious what the expected behaviour would be for a user who is not at all familiar with graphics API's Godot 3 (or OpenGL driver in Godot 4): I can immediately think of some use cases for the |
Thanks for investigating a little deeper. I think the best course of action is to switch the RD renderers to use REVERSE_SUBTRACT and make the change in 4.1 |
Cool, I'll put together a PR sometime in the next week-ish if nobody else has got to it before me. |
Godot version
master commit 2ab0f17 and later
System information
Windows 11 NVIDIA 980 Ti
Issue description
When working on #76334 I noticed that the RenderingDevice abstraction uses a different blend mode for
BLEND_MODE_SUB
than the OpenGL driver. RenderingDevice usesBLEND_OP_SUBTRACT
while OpenGL usesGL_FUNC_REVERSE_SUBTRACT
.In Godot 3, OpenGL uses
GL_FUNC_REVERSE_SUBTRACT
just like Godot 4's OpenGL driver.RenderingDevice Abstraction:
godot/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
Lines 221 to 222 in b7032b5
godot/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
Lines 210 to 211 in b7032b5
godot/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
Lines 2124 to 2125 in b7032b5
OpenGL:
godot/drivers/gles3/rasterizer_scene_gles3.cpp
Line 2177 in 4c677c8
godot/drivers/gles3/rasterizer_canvas_gles3.cpp
Line 738 in 4c677c8
This results in a different blend result when using the Subtract blend mode in different renderers:
Forward+:
Mobile:
Compatibility:
There appear to be some (relatively) minor differences between the Forward+ and Mobile renderers, but the difference to the OpenGL renderer is substantial because of the different blend mode function that is used.
Steps to reproduce
Important note:
If you are testing with a Godot 4 version earlier than master commit 2ab0f17, you must also set the Depth Draw Mode to Never as described in #76334 to correctly see the Subtract blend mode.
Minimal reproduction project
blend-subtract.zip
The text was updated successfully, but these errors were encountered: