- Home /
Magic Mirror - how to modify reflection?
Hey! I'm using Magic Mirror Lite from assets store. I really need a mirror that reflects inverted upside down room or rotated by 90 degrees. Example on image below - perspective is wrong but you get the idea.
At first I was trying to make my own mirror from scrath by using camera that rotates according to player's location and render image from this camera on render texture. It kinda works but it isn't realistic and looks more like a security cam. I tought I can also change FoV of camera according to distance between player and mirror and this is a little bit better but still isn't realistic enough. It doesn't behave like a real mirror and it distort the reflection. In this case it's simple to rotate reflection because I can rotate camera attached to mirror and reflection is rotated but I don't think I can make realistic reflection this way.
Or can I? Any ideas?
So I decided to use Magic Mirror, but really it's impossible to modify the reflection.
Rotating camera doesn't do anything.
I tought it is necesery to modify Matrix4x4 but I guess that's also not it.
I was also trying to flip mirrorMaterial Texture in MirrorCameraScript by mirrorMaterial.SetTextureScale("_MainTex", new Vector2(1,-1)); but again no luck...
I have no idea if shoud I somehow modify _MainTex inside shader or it is necesary to completely modify the way reflection is rendered?
I'm running out of ideas I spent weeks trying to figure it out.
Does anybody have idea?
I don't know about this $$anonymous$$agic $$anonymous$$irror. Did you try an orthographic camera too? $$anonymous$$ight be just what you need to avoid distortion? But I just don't know.
No it really doesn't make any sense at all, because ortogtaphic camera doesn't use perspective. And in mirror reflection I need perspective... In a really really big simplification objects closer to camera are bigger and objects further away are smaller. But ortographic camera basically shows two objects exactly the same size even if one is 1cm from camera and another is 100km from camera and that isn't reflection you supposed to see in a mirror.
Answer by Bodhid · Nov 27, 2018 at 12:15 PM
A simple planar mirror uses screenCoordinates in it's shader, so rotating the object has no use.
You can go to the mirror's update script, there will be a camera position and rotation set there. You can add an extra rotation there at the end. for example mirrorcam.Rotate(0,0,90); After all other positions and rotations are set.
What you can also do is change the uv coordinates in the material's shader. You can change tex2D(x,i.screenPos.xy) into something like tex2D(x,1-screenPos) or tex2D(x, float2(1-i.screenPos.x,i.screenPos.y) for example to flip the coordinates
Your answer
Follow this Question
Related Questions
Sun rays don't show up in mirror reflection in deferred rendering ? 0 Answers
Complete Flat Mirror Reflection shader 0 Answers
Cubemap/Reflection size/scaling issue? 0 Answers
Best option to create real mirrors in terms of performance 2 Answers
Problem with the mirror view made by reflection probe in android build 0 Answers