Making a reflective mirror

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CatRass

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

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 :smiley: hope someone has a good way, because i’m intereted too.

whiteshampoo | 2020-06-26 12:16

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

CatRass | 2020-06-27 08:24

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))); 

CatRass | 2020-06-27 08:49

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.

whiteshampoo | 2020-06-29 12:45

:bust_in_silhouette: Reply From: Czselu349

I think you may wanna check out this video:

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

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

CatRass | 2020-06-27 08:36