Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Dully |
So I had been following a 2D water reflection shader tutorial : https://www.youtube.com/watch?v=32jdNLTJ3zY&t=862s
But then this happened
Imgur: The magic of the Internet
from what I measured this is the problem
Imgur: The magic of the Internet
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);
}