In my 3D game, I have a TextureRect node with a “grimy paper” kind of texture that I’m overlaying on the viewport. I’m then setting the blend mode of the textureRect to be “multiply”, for an effect I want to achieve.
It looks the way I want, but there’s an issue: I can’t control the transparency of the overlay anymore, since the Multiply blend mode behaves in a way where I imagine it just ignores the alpha value of the texture. Not completely sure.
Is there any workaround? Can I parent the node to some specific transparency-based container or something? Or do I have to go hunting for a shader to accomplish this behaviour for me?
Thay unfortunately doesn’t work, it results in the same behaviour. Everything else fades as normal, but the multiplied texture gets roughly cut away only when reaching immediately 0 alpha value.
Maybe the shader code somehow overrided the effect that modulate has on these nodes.
That did the trick! Thanks, didn’t realize it would be so simple.
For future readers, this works with clamping as well, in a way. I use a two ColorRect nodes for my background, one which is just a black square with the alpha turned down to darken the screen, and the second one to which a script like the one bepis provided can be attached. That one’s kept as pure white.
Then in the node’s CanvasItem>Material you just attach the shader, set the texture you want to use (and write additional code as needed, maybe other blending modes etc) and it should work in accordance to the ColorRect’s expands and stretchings.
I haven’t really tested that out too much, and I’m using a texture of size 1920x1080, so other resolutions might demand something else. Also, I don’t imagine you’ll be able to zoom on the texture as the shader just overrides everything on screen equally (hard to explain), so in more specific cases this might be a difficult thing to do…
But for background/overlay images where the backround doesn’t move in any way this works great! Thanks again for the answer