Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

2D Radiance Cascades Usage Guide

This guide provides detailed information on how to effectively use the 2D Radiance Cascades lighting system in your Unity projects. It covers light contributor settings, built-in shaders, and custom shader integration.

Light Contributor Usage

The LightContributor component is the core element for adding lights to your 2D scenes. Different light types are available for various lighting scenarios.

Make sure to read about the different available light types in the General Concepts document.

Common Settings And Usage Tips

All light sources have a color controlled by these two settings:

SettingDescription
ColorSets the base color of the light source
IntensityControls the intensity of the light

The resulting light source color is obtained by multiplying the Color RGB components by Intensity. The two settings are provided for convenience, as a separate Intensity slider is generally more intuitive to use than a unified HDR color picker.

Setting either the Intensity to zero, or the Color to black turns the light into an occluder.

The intensity can be set to a negative value. This will turn a light source into a sort of "light sink." Which is not physically correct, but may be used for achieving various artistic effects.

img-sink-circle-posimg-sink-circle-neg
normal orange circle lightnegative orange circle light
img-sink-dir-posimg-sink-dir-neg
normal orange directional light (shining directly left-to-right)negative orange directional light
img-sink-dir-pos-circle-negimg-sink-base
normal directional light and negative circle lightbase image

Global Lights

Global lights (the Sky Light and the Directional lights) provide the ambient lighting. They are the most useful in outdoor scenes when no occluders or other light sources block them. The positioning of their transforms has no effect on how they work as lights.

Sky Light

The Sky Light type provides ambient illumination across your entire scene.

Directional Light

Directional lights simulate light coming from a specific direction, similar to sunlight. Effectively representing the light that is infinitely far away.

SettingDescription
TransformUse the standard GameObject's transform rotation to set the light direction
SoftnessControls the softness of the light source, or the size of the infinitely-far-away light. The range is 0–1, where 0 is a point light, and 1 is a light spanning across the hemisphere.

Tips

Be careful with sharp directional lights (softness close to zero). Being point light sources, they are easily missable when the lighting algorithm samples the environment light. Which may lead to various artifacts. There are some configurations that provide good results, though. E.g., the HRC variant when the lights are axis-aligned. See the examples below.

Examples
img-directional-hrc-0img-directional-hrc-20
Softness 0Softness 0.2
img-directional-hrc-50img-directional-hrc-100
Softness 0.5Softness 1

Artifacts examples

img-directional-hrc-rot-0img-directional-hrc-rot-15
HRC, Softness 0
(note the "hairy" border)
Softness 0.15
img-directional-bilinear-0img-directional-bilinear-15
Bilinear fix, Softness 0
(note the blocky shadow appearance)
Softness 0.15
img-directional-bilinear-rot-0img-directional-bilinear-rot-15
Bilinear fix, Softness 0
(note the blocky shadow appearance)
Softness 0.15

Analytical Lights

Analytical lights (circle, line, and freeform lights) represent light contributors made out of geometric primitives. Unlike Sprite lights, analytical lights can affect the scene even when they are outside the camera view.

All analytical lights provide the following properties:

SettingDescription
Single SidedWhen enabled, only one side of the primitive's surface interacts with the light. The opposite side is transparent
CullableWhen enabled, allows the light to be culled when outside the camera view
Cull DistanceMaximum distance (in world space units) at which the light affects the scene when cullable

Circle Light

Circle lights emit light from the surface of a circle.

SettingDescription
RadiusDefines the radius of the light source

Line Light

Line lights emit light along a line segment.

SettingDescription
LengthDefines the length of the light source

Freeform Light

Freeform lights allow for custom shapes defined by multiple control points. Effectively a chain of line lights stitched together and treated as a single object (i.e., all lines share the same properties, getting culled or not culled together, etc.).

SettingDescription
Control PointsA list of control point locations. Each point is a location where one line ends and the next one starts

Examples

In all the images below, the top shape is a normal double-sided orange light, the right shape is a normal double-sided occluder, the bottom shape is a single-sided blueish light, and the left shape is a single-sided occluder.

img-circle-lightsimg-line-lights
Circle lightsLine lights
img-freeform-lights
Freeform lights

Analytical Lights Editing Tools

Line And Circle Lights

Line and Circle lights provide handles for intuitive visual alignment of the lights:

img-edit-circle
Drag the handle to change the circle light radius
img-edit-line
Drag the handles to position the line light

You can also manually edit the Radius/Length properties for precise control.

Freeform Lights

To edit the freeform light, enter the edit mode in the editor window. The edit mode enables the following tools:

  • Scene handles: Interactive handles and buttons in the scene view allowing to visually inspect and modify the shape
  • Editable control points: Ability to manually modify the shape control points coordinates (in the local object space)
  • Helper editor tools:
ToolDescription
Close shapeCloses the shape by copying the first control point to the end. Inactive if the shape is already closed
Flip shapeFlips the shape from clockwise to counter-clockwise and vice versa. Inactive if the shape is double-sided
Load defaultLoads the default diamond shape instead of the current shape. Handy to start from scratch if something went wrong
Load Collider2D shapeLoads the shape from the Collider2D component attached to the same GameObject. Inactive if there is no Collider2D attached
img-edit-freeform-editor
Editor tools
img-edit-freeform-scene
Scene tools

Scene tools:

  • Use white handles to drag the existing control points
  • Use the red button to remove the nearby control point
  • Use the green button to place a new control point in the middle of the segment

Sprite Light

Sprite lights use a sprite texture to define the light shape and properties. Unlike other light contributors, sprite lights do not work outside the camera view.

SettingDescription
Light Source SpriteThe sprite to be used as the light source

Note that the sprite's natural color is multiplied by the light contributor color and intensity.

Light Configuration Tips

  1. Avoid tiny lights, as they are more prone to producing various visual artifacts.
  2. Don't neglect the culling options for the analytical lights, especially in bigger scenes with lots of light contributors.
  3. When possible, prefer analytical lights (Circle, Line, Freeform) over Sprite lights. As they are generally more versatile and provide more flexibility.
  4. In performance-critical scenarios, consider sticking to a single kind of lights in a scene. Both sprite-lights-only and analytical-lights-only setups will perform better than a mix of both kinds in a single scene.

Built-in Shaders and Materials Guide

The 2D Radiance Cascades system includes several built-in shaders designed to work with the lighting system.

Standard Lit Sprites

RC-Sprite-Lit-Flat

This shader provides basic lighting for flat sprites without normal mapping.

PropertyDescription
MainTexThe main sprite texture

Use Case: Ideal for simple 2D sprites that need to receive lighting but don't require advanced effects

RC-Sprite-Lit-WithNormal

This shader supports normal mapping for more detailed lighting effects on sprites.

PropertyDescription
MainTexThe main sprite texture
NormalMapThe normal map
DistanceThe height of the light above the surface

Use Case: Best for detailed sprites where you want to simulate surface relief and more realistic lighting

Follow the default Unity "Secondary Textures" approach to attach a normal map to your sprite.

The Distance parameter controls how high above the surface the virtual lights from the lightmap are, when computing the lighting. Higher values lead to softer, more uniform lighting, lower values lead to more dramatic lighting with more emphasis on the direction the light is coming from.

Note
Be careful with extra-low values. The lightmaps only capture light from four cardinal directions. Which is enough for soft diffuse lighting when the lights are considered relatively far from the surface. However, when the lights are close and are supposed to come at grazing angles, you may get noticeable artifacts due to the lack of angular resolution. See examples below.

Examples

img-mat-flatimg-mat-flat-circle
RC-Sprite-Lit-FlatRC-Sprite-Lit-Flat
img-mat-with-normal-20img-mat-with-normal-20-circle
RC-Sprite-Lit-WithNormal, Distance 20RC-Sprite-Lit-WithNormal, Distance 20
img-mat-with-normal-2img-mat-with-normal-2-circle
RC-Sprite-Lit-WithNormal, Distance 2RC-Sprite-Lit-WithNormal, Distance 2
img-mat-with-normal-05img-mat-with-normal-05-circle
RC-Sprite-Lit-WithNormal, Distance 0.5RC-Sprite-Lit-WithNormal, Distance 0.5
img-mat-with-normal-0img-mat-with-normal-0-circle
RC-Sprite-Lit-WithNormal, Distance 0RC-Sprite-Lit-WithNormal, Distance 0

See Also