How to make a mirror in Unity

There are two ways to make a mirror in Unity. One is using a camera and a render texture. The other technique uses smooth surface and reflection probes.

The reflection probes are performance heavy so we advise you not to use them. This tutorial will cover both methods.

We have two objects, a plane and a cube, in our scene. Let’s make a mirror to reflect these objects.

Make a Mirror using a secondary camera

Add a plane to your scene and name it Mirror.

Add another camera to your scene. Make sure to remove the audio listener component of this camera.

Create a new render texture by right clicking on the project window>create>Render Texture.

Name it as Mirror_texture.

Assign the Mirror_texture to the plane you created.

A new material folder will be created automatically when you assign the texture. Select the material and set the shader as Unlit>texture.

In the secondary camera select the Target texture as Mirror_texture

Now you should see the camera view on the plane.

Set your mirror(plane) in the direction you want.

Adjust the size of the plane to your requirement.

Make sure the camera is looking outwards from the mirror as shown in the image below.

Move an object in front of the mirror and you can see the object moves in the opposite direction. To fix this, just set a minus sign in the mirror transform scale. In my case the axis was z but it might differ based on how you have placed your mirror plane.

If you want a high-quality image on your mirror then you need to change the size of the texture.

Select the Mirror_texture and set the size to your requirement.

For fine adjustments move the camera forward or backward and also play with the field of view until you get the desired results.

Once all your settings are complete set the secondary camera as the child of the mirror so that the camera will follow the object if moved.

Make a mirror using Reflection Probe (performance expensive)

You need two things to make a mirror with a Reflection Probe. This method will not work if your target platform is Android.

  1. A smooth metallic surface.
  2. A Reflection Probe.

Create a new material by right clicking on the project window > create > material.

Name it as Mirror surface.

Set the Metallic and smoothness parameter to maximum.

Add a new cube to your scene. This will act as your mirror. Adjust the scale to make it look like a mirror.

Assign the Mirror surface material to this plane.

Add a new Reflection Probe to the scene by clicking Add>Light>Reflection Probe.

Set the Reflection Probe type to Realtime.

Refresh mode to Every frame.

Set Time Slicing to no time slicing.

Check the Box Projection check box.

Set the resolution depending on how good you want your mirrors image quality to be. Remember the bigger the number the more performance hungry the scene becomes.

Make sure the reflection probe is at the surface of the mirror plane.

You have learnt the two most basic ways to create a mirror in Unity. There are some 3rd party options for mirror assets in the Unity asset store that you can use.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.