Version: Unity 6.0 (6000.0)
Language : English
HDR emulation scale
Create 2D lit shader with Shader Graph

Add shadows from 2D lights in URP

To add shadows from 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), add the Shadow Caster 2D component to a GameObjectThe 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
. Follow these steps:

Note: To see cast shadows, you must have a 2D light 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
with its Shadows property enabled. For more information, refer to 2D lights in URP.

  1. Select the GameObject you want to cast shadows.
  2. 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, select Add Component.
  3. Type Shadow Caster 2D, then select the Shadow Caster 2D item.

Change the shape of a shadow

By default, the shadow is the shape defined in the Custom Outline window of the Sprite Editor. Unity displays the shape as a white outline in the Scene viewAn interactive view into the world you are creating. You use the Scene View to select and position scenery, characters, cameras, lights, and all other types of Game Object. More info
See in Glossary
.

To set a specific shape for the shadow, do the following:

  1. Select the GameObject with the Shadow Caster 2D component.
  2. In the Inspector window, set the Casting Source property to Shape Editor.
  3. Select Edit Shape.

Adjust the shape in the Scene view by doing the following:

  • To move a point, click and drag the point. You can also select the point, then manually enter the new position in the Position property of the Shadow Caster 2D component.
  • To add a point, click a line at the position you want to add the point.

Merge shadows from multiple GameObjects

To merge shadows from multiple GameObjects into a single shadow, add a Composite Shadow Caster 2D to a parent GameObject. Follow these steps:

  1. Create an empty GameObject.
  2. In the Inspector window, select Add Component.
  3. Type Composite Shadow Caster 2D, then select the Composite Shadow Caster 2D item.
  4. Add GameObjects as children of the GameObject in the Hierarchy window. If the child GameObjects have Shadow Caster 2D components, their shadows are merged.
Left: Two rocks cast shadows without a Composite Shadow Caster 2D component. The upper object casts its shadow onto the lower object. Right: The same rocks with a parent Composite Shadow Caster 2D component. The merged shadow is cast behind both objects.
Left: Two rocks cast shadows without a Composite Shadow Caster 2D component. The upper object casts its shadow onto the lower object. Right: The same rocks with a parent Composite Shadow Caster 2D component. The merged shadow is cast behind both objects.

Additional resources

HDR emulation scale
Create 2D lit shader with Shader Graph