Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Kanor |
I’ve been working with shaders to make a reflective-water shader. The problem is when it tries to reflect an area that is not on-screen:
shader_type canvas_item;
void fragment() {
vec2 reflection = vec2(SCREEN_UV.x, SCREEN_UV.y + UV.y*(SCREEN_PIXEL_SIZE.y/TEXTURE_PIXEL_SIZE.y)*2.0);
COLOR = texture(SCREEN_TEXTURE, reflection);
}
The problem is when reflection.y ends up being more than 1. Rather than correctly getting the look of a block from above the camera view, it gets the pixel color of the tip-top pixel on-screen. It CANNOT get values offscreen.
Is this intentional? Is there a way around it? I can live without it, but I’d like to have it if at all possible