Using Reflection Probe: Unity Tutorial

In this tutorial, we will see how to use reflection probe in unity applications.

Reflection Probe

A reflection probe is like a camera that stores the spherical view of its surroundings as a Cubemap. This Cubemap is then used to provide reflection on the objects having reflective materials. A unity scene can have multiple reflection probes.

We can generate three type of reflection probes:

  • Baked probe: stores baked cubemap in the editor and provide static reflection. Baked probes are good for performance.
  • Custom probe: stores static cubemap, can be baked in the editor or can be set manually by the user.
  • Realtime probe: stores dynamic cubemap that can be updated at the runtime. Realtime probes are not good for performance as it updates on every frame.

In this tutorial, We will see how to use a baked and realtime probe.

Set up Scene

  • Let’s set up a very simple scene for this demo.
    SceneCreate a reflecting object
  • Add a sphere in the scene. (Create -> 3D Object -> Sphere)
    Add Sphere
  • Create a material in the Assets folder (Create -> Materials) and apply it on the sphere.
  • Set the metallic and smoothness property of the material to 1. This will allow material to behave as a reflecting surface.
    Enable reflectionNow, you can see the skybox reflection on the sphere. But the scene game objects (Cubes) are not showing in the reflection of the sphere. We will fix this using reflection probe.

Set up reflection Probe

  • Add a reflection probe in the scene. (Create -> Light -> Reflection Probe).
    Add reflection probe
  • Place the reflection probe at the center of the Sphere object. (Copy transform component value from sphere object and paste it to the Reflection Probe object).
    Re center reflection probe

A Reflection Probe component is attached to the object. This component is like the Camera component and we can change the reflection behavior by changing the properties of this component.

Reflection component

Edit Bounding Volume

Edit the bounding volume of the reflection probe as per requirement. This will add scene objects from this bounding volume in the reflection.
Edit bounding Volume

Ignore Sphere GameObject

Since the reflection is displayed on the Sphere Game Object itself, so we need to ignore this while calculating reflection.

  • Create a new layer as ReflectionIgnore. Change the layer of the Sphere game object to this new layer. Checkout my layer mask tutorial to know more about layers.
    Reflection Igonre layer
  • Select Reflection Probe in scene and click on the Culling Mask dropdown property of the Reflection Probe component. By default, its value will be set to Everything. Uncheck the ReflectionIgnore layer.
    Culling Mask

Baked Reflection

  • By default, the reflection type is baked. To include the objects, present in the bounding volume, we need to bake the lighting once again.
    Type - Baked
  • Set environment objects as reflection static. Select the Environment object and mark it reflection static. If a pop up will ask to mark the same change for the child objects then click on Yes button.
    Static
  • Open Lighting panel (Window -> Rendering -> Light Settings). In the Debug Settings section, uncheck the Auto Generate check box.
  • Click on the Generate Lighting button. Reflection will be now baked again.
    Generate lighting
  • The environment objects are now the included in the reflection.
    Baked

Real time Reflection

  • Since the above reflection is baked, if there will be any change in the environment objects at run time then it will not reflect on the reflecting surface. For example, if the cube objects will change its position at run time, it will not reflect in the reflection. We can use real time reflection in this scenario.
    Baked Problem
  • Change Reflection Probe type to Realtime. It will enable two more options. Change refresh mode property to Every Frame and Time Slicing property to No time slicing.
    Real time settings
  • Check Autogenerate checkbox in Lighting panel (Window -> Rendering -> Light Settings -> Debug Settings)
  • Now the reflection will update on every frame.
    Real time

Try to manipulate different properties of Reflection Probe component and see the results on the reflection.

Download the example unity package here.

That’s it for the tutorial. Please post your comments for queries and feedback. Thanks for reading.

Share Button
The following two tabs change content below.
Gyanendu Shekhar is a technology enthusiast. He loves to learn new technologies. His area of interest includes Microsoft technologies, Augmented reality, Virtual reality, unity3d and android development.

Latest posts by Gyanendu Shekhar (see all)

Gyanendu Shekhar

Gyanendu Shekhar is a technology enthusiast. He loves to learn new technologies. His area of interest includes Microsoft technologies, Augmented reality, Virtual reality, unity3d and android development.

Leave a Reply

Your email address will not be published. Required fields are marked *