How to make a horizontal mirror effect in shader

Godot Version

4.6.1

Question

Hello i am makekin a game where mirror are a main elemen

I already did vertical mirror effect following tutorials

but I need horizontal mirror effect where mirror player movement is reverse for actually player

sorry for my bad english

I try switch x and y and change code to reverse

But only two thing happened

1 is that it switch mirror effect to side

2 is stay Norman but Little up the original

void fragment() {

        vec2 uv = UV + nopeus * TIME;

        vec2 aani = texture(nopee_aani, uv).rg;

        float uv_koko = (SCREEN_PIXEL_SIZE.x / TEXTURE_PIXEL_SIZE.x);


        vec2 x_Heijastuksia_uv = vec2(SCREEN_UV.x, SCREEN_UV.y - (uv_koko  * UV.x * scale_x * x_zoom));



        vec4 Heijastuksia = texture(SCREEN_TEXTURE, x_Heijastuksia_uv);



        vec4 aalto = texture(SCREEN_TEXTURE, x_Heijastuksia_uv + aani * x_zoom * (aaltojen_voima / 100.0));



        COLOR = Heijastuksia + aalto + CAST_color;
}

Create Water Refletions in Godot 4 | Shader Tutorial

It work now

I have to just switch

vec2 x_Heijastuksia_uv = vec2(SCREEN_UV.x, SCREEN_UV.y - (uv_koko * UV.x * scale_x * x_zoom));

to

vec2 x_Heijastuksia_uv = vec2(SCREEN_UV.x - (uv_koko * UV.x * scale_x * x_zoom), SCREEN_UV.y) ;

1 Like

If you fixed it by changing something I think it would be great if you wrote how you fixed it just in case someone finds this post later on and is having a similar issue so that they cns then find the fix.

(Thanks for doing that. Always try to think of the people who have the same issue later on)

Anyways hope you have luck on whatever this project or just learning experience is.

1 Like