Light Layers in Unity

Light layers are a form of Layer Mask that allows lights in a scene to only enact on specific meshes. This can allow us to create certain effects, or to further enhance the realistic aspects of illuminating our scene.

To use light layers we must first enable them in the Inspector of the HDRP asset. We can now see a number of layers we can rename and use for different elements in our scene.

Now we can have our lights only affect certain meshes by first selecting a Light Layer on a light component. This can be seen by clicking the settings cog in the top right to show more options.

Selecting a Light Layer at this point in time, will result in the light not actually illuminating any meshes until we add them to the same layer.

This is actually one way we can make use of Light Layers if we were to have volumetric lighting, as this enables us to see the emitted light without actually affecting objects in our scene.

Light Layers disabled vs enabled

If we do want to have specific objects align with our lights though, we can set the Layer within the object’s Mesh Renderer.

Using Light Layers to only illuminate the tubes

When using Light Layers, we inevitably will manipulate how shadows are cast too. If various layers are in use, meshes will only cast shadows in the lights that are functioning on the same Light Layer. If we want to, we can actually delink the shadow Light Layers from the Light Layers. In the selected light’s Inspector, if we navigate to the Shadows section and select more options, we can then disable Link Light Layers. This provides a drop down menu to select which layers we want to allow to cast shadows.

Shadows following Light Layers vs ignoring the tubes

Ultimately, this can allow for many different variations of light and shadow casting for each light source! If we were to alter code in real time, I’m sure we could also create some really cool dynamic effects!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store