Godot Version
4.3
Question
So I am making a 2D top down game and I want to make a glossy floor, meaning that the floor should reflect everything. I have made a shader that works, but only for the player. I have a player scene that has a camera2D following the player. Whenever the player moves the reflection is under him, but all of the objects that dont move have the reflection move with the player also. I want the reflection for the object that dont move to be always underneath them and never move. I have little to no experience with shaders and would really appreciate if somebody would help me out ![]()
This is the shader:
shader_type canvas_item;
uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap;
uniform float reflection_strength : hint_range(0.0, 1.0) = 0.35;
uniform vec3 reflection_tint : source_color = vec3(0.9, 0.9, 1.0);
uniform float floor_visibility : hint_range(0.0, 1.0) = 0.7;
void fragment() {
vec2 uv = SCREEN_UV;
uv.y = 1.1 - uv.y;
vec4 reflection = texture(SCREEN_TEXTURE, uv);
reflection.rgb *= reflection_tint * reflection_strength;
vec4 floor_color = COLOR;
// Make the reflection layer semi-transparent
COLOR.rgb = mix(reflection.rgb, floor_color.rgb, floor_visibility);
COLOR.a = reflection_strength; // Use strength as alpha
}