Fixed issues with blend modes in OpenGL 3 renderer#77409
Conversation
There was a problem hiding this comment.
I'm not sure about this. In Godot BLEND_MODE_SUB means that the color from the pixel shader is subtracted from the color behind it. That corresponds to GL_FUNC_REVERSE_SUBTRACT. GL_FUNC_SUBTRACT subtracts the background color from the pixel shader color and returns that value.
I.e. if you want to write a white pixel to a grey background with GL_FUNC_REVERSE_SUBTRACT you get (0.5, 0.5, 0.5) - (1, 1, 1,) = (0, 0, 0) while with GL_FUNC_SUBTRACT you get (1, 1, 1) - (0.5, 0.5, 0.5) = (0.5, 0.5, 0.5)
There was a problem hiding this comment.
Ah, I see that the OpenGL renderer has always used GL_FUNC_REVERSE_SUBTRACT for BLEND_MODE_SUB. Thanks for pointing this out! I will remove this from the PR.
The reason that I initially made this change was to match the behaviour of the other two renderers in Godot 4 which use BLEND_OP_SUBTRACT instead of BLEND_OP_REVERSE_SUBTRACT:
godot/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
Lines 2124 to 2125 in b7032b5
I will open a different issue sometime later regarding the inconsistency of BLEND_MODE_SUB when using different renderers in Godot 4.
There was a problem hiding this comment.
Ah, good catch. So it seems the RD backends are reversed. That actually explains some things
|
Thanks for taking a look at this. It is super helpful to have others working on the opengl backend |
I appreciate this! There's always some challenge with approaching a new open source project, so this feels good to hear. I also believe that one of the top 2 or maybe the top value of a game engine is portability across all devices, including old ones, so the OpenGL backend remains very important. |
Added uses_blend_alpha = true for ADD, SUBTRACT, and MULTIPLY blend modes to match the other renderers Fixes godotengine#76334
9b5a28c to
51f0e36
Compare
|
Thanks! And congrats for your first merged Godot contribution 🎉 |
Added uses_blend_alpha = true for ADD, SUBTRACT, and MULTIPLY blend modes to match the other renderers.
Fixes #76334