The High Definition Render Pipeline (HDRP) allows you to use Light Layers, which are LayerMasks, to make Lights in your Scene only light up specific Meshes. You set Light Layers for Lights and Meshes to make Lights only affect Meshes that are on corresponding Light Layers.
Enabling Light Layers
- Select the HDRP Asset in the Project window and, in the Inspector, go to the Lighting section and enable the Light Layers checkbox.
- To enable Light Layers in the default Frame Settings for all Cameras, in your HDRP Asset, go to the Default Frame Settings For section, select Camera from the drop-down and, in the Lighting section, enable the Light Layers checkbox.
To override the Frame Settings for Cameras and set Light Layers on an individual basis:
- Click on a Camera in the Scene view or Hierarchy window to view its properties in the Inspector.
- Go to the General section and enable the Custom Frame Settings checkbox. This exposes the Frame Settings Overrides, which you can use to customize this Camera only.
- In the Lighting section, enable the Light Layers checkbox to make this Camera use Light Layers.
Using Light Layers
After you enable Light Layers, you can then use them to decouple Meshes from certain Lights in your Scene. To do this:
- Click on a Light in the Hierarchy or the Scene view to view it in the Inspector.
- Expose the advanced properties in the General section to expose the Light Layer property.
- Use the Light Layer property drop-down to select which Light Layers this Light affects.
- Click on a Mesh Renderer in the Hierarchy or the Scene view to view it in the Inspector.
- Use the Rendering Layer Mask drop-down to select which Light Layers affect this Mesh Renderer. When you enable Light Layers, a Light only affects a Mesh Renderer if they both use a matching Light Layer.
Using cookies for light fixtures can sometimes have a negative visual effect on a bulb, such as self-shadowing or transmission contribution. You can use Light Layers to make a bulb Mesh not receive any light from the Light’s cookie, and instead receive light from a separate small Point Light.
The Light cookie incorrectly affects the transmission of this bulb’s geometry.
Assigning the bulb’s Mesh Renderer to a specific Light Layer means that the Light cookie no longer affects the bulb’s Mesh Renderer.
To restore the transmission effect, create a Point Light and assign it to the same Light Layer as the bulb’s Mesh Renderer . Now this Point Light only affects the bulb’s Mesh Renderer and does not contribute to the rest of the Scene Lighting.
For more information on this process, see Pierre Donzallaz’s expert guide on creating high quality light fixtures in Unity.