Godot 4.1
Hello everyone,
I’m working with a shader in Godot and have a specific requirement for which I need some guidance. Here’s the code snippet I’m currently using:
shader_type canvas_item;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture;
uniform sampler2D SPRITE_TEXTURE; // Texture of the sprite
void fragment() {
vec4 screen_pixel = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0);
vec4 sprite_pixel = texture(SPRITE_TEXTURE, SCREEN_UV);
if (screen_pixel.a <= 0.5) { // Checking if the pixel on the screen is transparent
COLOR.a = 0.0;
}
}
I want to achieve the following effect: the object should become transparent when it intersects with a semi-transparent object. Could you please advise on how to modify this shader to implement this functionality?