0 votes

So I had been following a 2D water reflection shader tutorial : https://www.youtube.com/watch?v=32jdNLTJ3zY&t=862s
But then this happened
https://imgur.com/a/X6GwZPQ
from what I measured this is the problem
https://imgur.com/Q7kTsau
Red line is the SCREENTEXTURE and blue line is the REFLECTIONTEXTURE
as you can see, they have the same length which mean that the problem is about how the SCREENTEXTURE works. SCREENTEXTURE only include the part that we can see in the camera but not the part behind it. After searching for 1 hours I can't still find a solution to this problem, any help is appreciated. Thanks

Also this is the shader:

shader_type canvas_item;
uniform vec2 scale;
uniform float zoom;
void fragment(){
    float uv_height = SCREEN_PIXEL_SIZE.y / TEXTURE_PIXEL_SIZE.y;
    vec2 refl = vec2(SCREEN_UV.x, SCREEN_UV.y + uv_height * UV.y * scale.y * zoom * 2.0);
    COLOR = texture(SCREEN_TEXTURE, refl);
}
Godot version 3.3.2
in Engine by (31 points)
edited by

1 Answer

+2 votes
Best answer

Hi!
Since this is a screen-space shader this is totaly normal.

Usually you would fade out the reflection when the "ray" leaves the screen (this is done in SSR) or you can avoid this when your mirror is below the center-line.

... or you have to render your reflection whith a totaly different method.

by (3,932 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.