Godot Version
v4.4.1.stable.mono.official [49a5bc7b6]
Question
How can I exclude CanvasModulate node’s effect from a certain Sprite2D node?
v4.4.1.stable.mono.official [49a5bc7b6]
How can I exclude CanvasModulate node’s effect from a certain Sprite2D node?
Hi,
Checking Top Level
would work but comes with other side effects you probably do not want. See the documentation if needed: CanvasItem — Godot Engine (stable) documentation in English
Another technique would be to add a shader material with a custom shader on the Sprite2D you want to ignore the color modulating on. The shader would just override the fragment’s color for the base texture, like this:
shader_type canvas_item;
void fragment()
{
COLOR = texture(TEXTURE, UV);
}
That’s the full shader, so it’s nothing much to implement.
Last solution to my knowledge would be using Self Modulate
on parent nodes instead of Modulate
, and work on some handmade code to spread a color to all children, while ignoring some of them.
Basically, a custom modulate with the ability of ignoring some CanvasItems. That would probably be a bummer to implement, but I have no context on your use case, so I’m sharing that just in case.
(Ignore my earlier response, I tested it and it didn’t work as I wanted)
In my specific case, I need to partially darken certain sprite that out of player vision. CanvasModulate work, but it affect everything, which I don’t want.
Could you share a bit more context, probably a screenshot?
oh I solved it, sorry for bothering you, I just make the light texture bigger and it worked great.
The only thing I would want to know is if you can point to some resources where I can learn how shader work (Godot and in general).
That’s all. Thank you!
Check out The Book of Shaders. A comprehensive guide to shaders: