Luminance¶
The Sight sensor of a Perception component has the option to Use Luminance in order to account for an object's reflected light when determining whether it is visible or not, and how much should the Awareness increase based on its intensity.
Unity uses the Light component to specify light entities, which can take different shapes (Spot lights, Directional lights and Point lights) as well as affecting the scene during the light baking process or in real-time.
Component¶
The Perception module supports all these shapes and lighting modes through the use of the Luminance system, which is a component attached to any light source which indicates that this specific light should affect how visible an object is in the scene.
The Luminance component will automatically detect the type of light and shape.
Luminance on Lights
As a general rule of thumb, all Light components should also have a Luminance component attached to them. However you might also want some lights not to affect player's visibility.
For example, if the player puts on some night vision goggles, you could enable a spotlight in front of it with a green tint that doesn't have any Luminance component attached to it. This will prevent this light from affecting visibility.
The Multiplier field allows to modify the luminance value compared to the Light's intensity.
Dim Light
For example, let's say our game is set in a very dark room and one of the light sources is a small lamp. But because it's very dark, the intensity of the light must be increased, but we would like the Luminance value to stay low.
In that case we can use a 0.5 multiplier so that if our Light intensity is 2, the resulting luminance value is 2 * 0.5 = 1.
The Layer Mask allows to pick which objects do affect luminance. It is important to note that luminance is calculated based on colliders, not on general geometry. If an object (like a fence) doesn't have a collider, although light will be blocked by the opposite side of the fence, the luminance value will still reach the other side.
Add colliders to geometry
It's advised to add colliders to every piece of geometry in the level so that both light and luminance result in similar results.
Transparent geometry
If you have a glass door in your game, light will pass through it and hence luminance should lit objects behind it. In order to achieve this, simply place the collider of the glass door in a Layer that isn't affected by the Luminance's Layer Mask.
Environment Luminance¶
The Environmental Luminance can also be set using the Change Global Luminance instruction. This instruction changes the minimum light intensity the scene has, even there are no lights in the scene.
This is useful if the Light Window has a bright environment light color or sky-box.
Checking Luminance¶
Once all Luminance components are set up the resulting Luminance value can be queried at any point in the scene using the Luminance property, which is a decimal value that represents the intensity of the overall light hitting that spot.
UI
There is a UI component that allows to display UI information about the Luminance in real-time to the player. For more information, visit the Luminance UI section.