In our last tutorial on Unity lights, we learnt that baked lights do not affect dynamic objects. You can very well use a real time light to solve this issue but having multiple real time lights in your scene can really affect the performance. Also, gameobject are affected only by direct light in case of real time light. Unity has a sollution for this and it’s called Light Probes.
What are Light Probes in Unity?
Light Probes store the light information about the light passing through the empty space where the Probes are located. They store information like the direction of light and the intensity. This information is then used to light any dynamic objects around the Probes.
Without Light Probes, the dynamic object is only lit by direct lighting. Usage of Light Probes is not only performance effective but also makes the scene look good.
Difference between Lightmap and Light Probe
A lightmap saves the light information falling on a gameobject like a plane. The light data is saved like a texture and applied while rendering the object on camera. We can create a lightmap by baking the lighting data of a scene. As mentioned earlier, the lightmap data is used to light only the static objects in the scene.
A Light Probe on the other hand saves the light data in open space, which are used to add lighting to a dynamic object. But the Light Probes need to be placed manually by the developer.
How to add Light Probes to your scene
Step1: Adding a Light Probe Group
Go to the Hierarchy window and click on the + sign. Then go to Lights>Light Probe Group.
This will add a group of Light Probes in your scene.
Step2: Adjusting the Light Probe’s position
Select the light probe and click on Edit Light Probe. Now you can move the Light Probes to any position you like. It is best to move the Light Probes to where there is change in light intensity or direction. You can add more Light Probes by selecting the existing probes and duplication them.
A Light Probe should not be place inside an object. This will lead to computational error and irregular lighting.
Step3: Baking the Light
You need to bake the light again after adding the Light Probes. To bake the light, go to Window>Rendering>lighting. Click on generate lighting in the scenes tab. Here is our scene after baking.
After placing the Light Probes and baking the light, if you place a dynamic object in scene, Unity should add light to it. The data for the light will be taken from the Light Probes. You can see which light probe data is being used in Unity scene view.
Advantages of Light Probes
- Realistic lighting: Light Probes allow objects to appear more realistically lit in a scene by capturing and reflecting light information from the environment. This helps to create a more immersive experience for the user.
- Dynamic lighting: Light Probes can capture dynamic lighting changes in a scene, such as the movement of the sun or changing weather conditions. This allows for realistic lighting changes to occur in real-time.
- Optimization: Light Probes can help optimize performance in a scene by reducing the number of lights needed to create realistic lighting. This can lead to better performance and faster frame rates.
Disadvantages of Light Probes
- Limited range: Light Probes have a limited range of influence, meaning that objects outside of the range may not appear correctly lit. This can be a problem for larger scenes or outdoor environments.
- Time-consuming: Creating and placing Light Probes can be time-consuming, especially for complex scenes. This can lead to longer development times and potentially higher costs.
- Limited accuracy: Light Probes may not capture all lighting information accurately, which can result in objects appearing incorrectly lit. This can be especially noticeable in certain lighting situations, such as shadows or reflections.
That is all about the basics of Unity Light Probes. If you have any questions then feel free to leave them in the comment box below.