Godot Version
4.3
Question
I’m trying to write a shader that blends a texture with everything in the background using the multiply blending technique.
I know I can use render_mode blend_mul
for this, and although that works, I want to be able to turn the effect on and off with a bool later.
I came up with this shader code, simplified to show my problem:
shader_type spatial;
render_mode unshaded;
uniform sampler2D _texture: source_color;
uniform sampler2D _screenTexture : hint_screen_texture;
void fragment()
{
vec4 textureColor = texture(_texture, UV);
vec4 backgroundColor = texture(_screenTexture, SCREEN_UV);
vec4 blend = backgroundColor * textureColor;
ALBEDO = blend.rgb;
}
The problem is that it doesn’t seem to blend with the other mesh textured with the same shader underneath.
My shader code that doesn’t blend well with its background:
The way it should look: