Godot Version
v4.3.stable.steam [77dcf97d8]
Question
Hi, i’m trying to create a grey-scale shader for custom buttons in my game (so the regular button disabled StyleBox is insufficient). The way is works is I draw ColorRect with a custom ShaderMaterial over the entire button, effectively turning it grey-scale, see shader code below.
Now, this works great for the induvial node scene (figure1), however, I have multiple buttons in my UI (figure2) and it seems only the first button in the tree works correctly with the shader (figure3) (as if the shaders SCREEN_TEXTURE, dose not detect any UI nodes after the first instance (even when the material is set to local to scene).
Anyways, I have a few (bad) work arounds for this, however, I would like to know what the optimal solution is.
figure1
figure2
figure3
Shader (copied from online)
shader_type canvas_item;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture;
void fragment() {
COLOR = texture(SCREEN_TEXTURE,SCREEN_UV);
COLOR.rgb = mix(vec3((COLOR.r + COLOR.g + COLOR.b) / 3.0), vec3(0.299 * COLOR.r + 0.587 * COLOR.g + 0.114 * COLOR.b),0.0);
}