The Power of Light Probes in Unity
The general way to illuminate objects in a 3D space is by ‘baking’ lighting information into those objects. This works well for static objects, but in video games we have dynamic objects that need to capture lighting information in real time as they move around. We can use realtime light sources, but these can be intensive as they have to calculate information every frame.
A lesser intensive but largely productive way of achieving this is using Light Probes. Light Probes in Unity, allow us to capture baked lighting data from static objects in multiple positions to approximate indirect light values for surrounding dynamic objects.
To set up a Light Probe Group, we create a web of probes across the areas in which we want objects to interact with baked light data. This can be time consuming, but is done with ease through duplication and the standard transform controls.
Static and Dynamic objects don’t necessarily have to adhere to their namesake, all that defines a static object in this sense is if it has the Contribute GI tag. Having this tag set allows for that object to bake lighting data. Most large objects in a room should be set to static such as walls, ceilings and floors, or even large props, so that each of these pass indirect light around the scene. Many smaller items may be naturally considered static, but realistically small objects don’t reflect much light, so there’s little point in baking them, therefore they’re considered dynamic despite being immovable. In some instances, we want lighting to turn on and off, in which case, we shouldn’t make objects like our walls static, as we want light information to occur dynamically.
Therefore, what we set to Contribute GI depends on the scope of a project. If we have large immovable items that don’t need to receive any lighting changes, they can be considered static, everything else is dynamic and can receive light information from either realtime lights or light probes.
This scene has baked lighting data from a singular mixed spotlight on the ceiling, with the walls, ceilings, and floor set to Static. With our Light Probes enabled, we can see our scene appear more visible due to the dynamic objects receiving estimated light data from the probes to create a more natural look.
We can also set Emissive objects to Contribute GI, so as to produce ‘fake’ light sources for our Light Probes to interact with. The green glow below is baked into the walls and floor, allowing for the smaller objects such as the desk and locked to receive a green glow without any proper light component.
To visualize the effect of light probes, we can make use of the Light Probe gizmo when selecting objects in our scene. This gizmo allows to see the web of probes that the object is receiving information from. Light sides of the probe show where baked light is emitted from, whereas the dark side shows the shadows.
We can also see the probes capturing the colored lighting data from our static emissive objects as opposed to just light and dark values.
Below, we can see how a true dynamic object reacts as it moves through the different probes. While this is a fairly static scene with minimal gameplay, Light Probes could be super useful in scenes with third person characters, as well as moving objects through lit areas.
Sometimes we want more bouncing of light from our static objects, to achieve this, we can make use of the indirect multiplier value on our different light sources. This multiplies the baked lightmap and light probe data that emits onto our dynamic objects. Alternatively, if we want to do this for our whole scene, we can make use of the Indirect Lighting Controller override on our Post Processing Volume.