Control Your Lighting in Unity Using Light Layers

Objective: Learn what Light Layers are, how they work, and a simple way to use them.

What are Light Layers?

This feature, which is part of the High Definition Render Pipeline(HDRP), allows you to direct the lights in your scene to only illuminate specific Meshes by using Light Layers, which are LayerMasks.

To explain the concept of LayerMasks a little further, all objects exist on a single layer, however, layers aren’t used directly by Unity APIs that let you choose which layers the API affects. In other words, the APIs don’t give you the ease of access to choose what layers it affects and what layers remain untouched. This is where layerMasks come in, a layerMask is a standard integer written as a bitmask, where each 1 denotes a layer to include and each 0 denotes a layer to omit.

Let’s take a look at a simple example of how to apply Light Layers!

Using Light Layers

Note: Remember that to follow along this example you must be using an HDRP project template.

  1. Add a light source, in this example I’m using a spotlight and setting its cone parameters a little something like this:

This is a pretty wide cone to cover a large area. The intensity of the light is going to be very high as well, but feel free to play with your own parameters.

Here you can see how I’ve positioned my Spotlight on my Control Room Level.

Note: This control room level has been covered in several of my level design articles, feel free to check those out to learn more! :)

2. Now, it’s time to enable Light Layers. You can do this via Asset Folder →Settings → HDRP Default Resources →HDRenderPipeline Asset.

3. Select your light source in the Hierarchy then scroll to the General section in the Inspector. If the Light Layer option is missing, make sure you click on the 3-dotted many beside the question mark and Show Additional Properties.

4. When you open the Light Layer dropdown menu, you will notice that everything is selected. Instead of going through that long list and unclicking everything, you can simply select Nothing and then select whichever Layer you want to be affected.

Since I don’t have any layers set to any of my light sources yet, I can just pick the first later. Since nothing is assigned to this layer, this means the light source will be present in my scene but not actually lighting up the objects in front of its cone.

The Difference: In the image below, you can see how assigning this layer stops the spotlight from lighting the object within its range. Then when I reset the layer settings to default(to what it was before step 4), you can see how the object lights up again.

Note: Notice how the Spotlight is still emitting light within range, its simply not affecting the objects around it by not making them appear litup— that’s part of the Light Layer magic. What can this be useful for? One example used often is for Godrays and other lightsources that go along volumetric lighting and fog.

5. After positioning my light, I added a green tint to it to match the mood of the control room and compliment the green fog in front of it.

6. Lastly, I duplicated the Spotlight and positioned it on the other side of the altar overlooking the test tubes.

The Result

You can see a faint natural light enhancing the appearance of the green fog.

For reference, here you can see what the scene looked like without this lighting.

Thank you for your time! If you found this information valuable give me a follow! :) I document my learning journey into Unity Development and Software Engineering in the form of tutorials!

--

--

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
Dennisse Pagán Dávila

Dennisse Pagán Dávila

An ambitious writer seeking to learn more about game development and software engineering. In this documentation hub, I share my skills and learning