Version: Unity 6.6 Alpha (6000.6)
Language : English
Introduction to 2D lighting in URP
Make a GameObject compatible with 2D lights in URP

Create a 2D light in URP

Create a 2D light in the Universal Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info
See in Glossary
(URP). 2D lights illuminate compatible 2D GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
in your sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary
.

Follow these steps:

  1. Right-click in the Hierarchy window, then select Light.
  2. Select one of the built-in 2D light types. If you create a custom 2D light type, the custom light type also appears in the list.

By default, spritesA 2D graphic objects. If you are used to working in 3D, Sprites are essentially just standard textures but there are special techniques for combining and managing sprite textures for efficiency and convenience during development. More info
See in Glossary
and tiles you drag into the Scene view use the Sprite-Lit-Default shaderA program that runs on the GPU. More info
See in Glossary
, which is compatible with 2D lights.

You don’t need to move 2D lights forward or backward. 2D lights and shadows affect all GameObjects regardless of the distance between the light and the GameObject.

Note: 2D materials from the Built-In Render Pipeline don’t react to 2D lights. To upgrade materials from the Built-In Render Pipeline to the Universal Render Pipeline, refer to Migrate from the Built-in Render Pipeline to URP workflow.

If you use the Scriptable Render Pipeline (SRP) Batcher, set the Mode property of tilemapsA GameObject that allows you to quickly create 2D levels using tiles and a grid overlay. More info
See in Glossary
to either Individual or SRP Batch to improve performance. Chunk mode is incompatible with the SRP Batcher. For more information about the Mode property, refer to Add 3D height to an isometric tilemap.

Configure which lights affect which GameObjects

By default, a 2D light affects all 2D GameObjects in the scene. To specify which GameObjects a light affects, follow these steps:

  1. Assign the GameObjects you want the light to affect to a single sorting layer. For more information, refer to Sprites sorting order.
  2. Select the 2D light in the Hierarchy window.
  3. In the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
    See in Glossary
    window, in the Light 2D component, set Target Sorting Layers to the sorting layer.

When lights affect different sorting layers, performance can decrease because Unity renders more light and shadow textures. For more information, refer to Optimize 2D lights with batching.

Add volumetric lighting

All 2D lights can create volumetric light, which is visible light in empty space. Follow these steps:

  1. In the Inspector window of the 2D light, enable Volumetric.
  2. Set Volume Intensity to a value above zero. The higher the value, the more visible the volumetric light is.

Avoid self-intersection in Freeform lights

If you create a Freeform Light 2D, the light might not appear in areas where the light overlaps with itself.

Left: Outline self-intersection in Edit mode. Right: Light effect with a black triangular artifact.
Left: Outline self-intersection in Edit mode. Right: Light effect with a black triangular artifact.

To avoid this, do the following:

  1. Make sure the edges of the shape don’t cross over each other.
  2. Set the Falloff properties of the light to ensure the light doesn’t overlap itself.

Additional resources

Introduction to 2D lighting in URP
Make a GameObject compatible with 2D lights in URP