+3 votes

What's the best way going about making a mirror that reflects everything that's in front of it?

in Engine by (49 points)

if it does not need to be a perfect mirror:
Apply a Matrial with Metalic: 1.0 and roughness: 0.0 and enable SS Reflections in you Environtment.
For a "real" mirrro: i have no idea :D hope someone has a good way, because i'm intereted too.

Ok thank you, I'll look into it :>

So, I've found a 2D shader that works, but the reflection is upside-down, and I'm not sure how to fix it, heres the shader code:

shader_type canvas_item;
render_mode unshaded;

void fragment(){

    vec2 uv = SCREEN_UV;
    float y = 1.0 - uv.y;

    COLOR = vec4(texture(SCREEN_TEXTURE, vec2(uv.x, y))); 
} 

Short answer is:

shader_type canvas_item;

void fragment()
{
    COLOR = texture(SCREEN_TEXTURE, vec2(1.0 - SCREEN_UV.x, SCREEN_UV.y));
}

but thats not practicable and not nice...
and the problem is much more difficult than i thought...
i'm lacking some knowlege here and still trying to get something better working...
i'll let you know when i found a good solution.

1 Answer

0 votes

I think you may wanna check out this video:
https://www.youtube.com/watch?v=cWpFZbjtSQg

It's using unity, (And it's about portals) but i think that a lot f ideas could be used from it.

by (137 points)

I'm sorry but I forgot to mention that I wanted this in 2D. Anyways to make it in 2D?

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.