Godot Version
4.3
Question
I am creating a game with some shaders in the UI, there are currently 2 nearly identical shaders for the text, 1 for player health and the other for a boss health. The shader is very simple, it turns white when the screen below is dark and the other way around.
< The shader
In their respective scenes both of these shaders work fine but when they are both in the main scene only the one which enters the scene tree first works.
(ignore the messy tree please :))
Even wierder is that when the first text which holds the shader is not visible in the editor, the second one works as expected:
Does anybody have a solution to this issue? I would love to hear any suggestions.
Are you applying the material to the Control node or the text node specifically? Overlapping screen-space effects can behave in very strange ways.
The material is only applied to the Label with the text on it, I did just find out that the shader only ignores the ColorRect below it since it does work when I put something dark behind it.
Does the color rect have some alpha value, anything below 1.0? Transparent things may also not work in screen textures
No, the color rect is fully opaque.
By default, the screen texture snapshot is made only once per frame right before the first shader that uses it is about to be drawn. So all other shaders will receive that same copy of the screen texture, resulting in nodes that come after the first appearance of the shader in the scene tree - not being drawn into the screen texture.
Use BackBufferCopy node to force multiple snapshots of the screen texture at places you need it.
2 Likes
Ah thanks, it seems to work now.
1 Like