Creating A Mirror In Unity (Basic Version)
Mirrors in games are an immersive feature and are often noticed by players. However, the performance costs of realistic mirrors sometimes make the developers avoid them for now.
Today’s Objective: Create a mirror which reflects what’s in front of it, in a simple low-performance-cost way.
Creating the mirror:
Create a new 3D object (I use a plane) and position it where you want your mirror to be.
Create a new Camera as a child object of the mirror.
Create a new Render Texture and a new Material.
Set the material to use the Unlit/Texture shader and the Render Texture as its texture.
On the Camera child object, set the Render Texture as its Target Texture.
Ensure the correct position of the Camera and set it to Orthographic. Make sure the orthographic size fits the whole mirror.
On the Render Texture, set the size to be at a resolution you think is appropriate. Higher = higher resolution in the mirror, lower = lower resolution. I found that 2048 x 2048 was basically a 1:1 resolution.
Drag the mirror material (that is using the Render Texture) onto the mirror to set it as the mesh’s material.
Negatives for this method:
This method only “reflects” exactly what is in front of the camera, with no awareness of what angle you are viewing the mirror from. So regardless of where you view the mirror from, it will always show the same “reflection”, and that’s unrealistic.
I’ll post a second guide to making an advanced (realistic) mirror very soon, which will require some code.