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

Getting Started with 2D Radiance Cascades

Installation

The package is provided as a hybrid package. To install it, import the .unitypackage file into your project or install it from the Unity Asset Store. The package contents will appear under Packages/com.dim0v.radiance-cascades-2d and it will generally work as a local UPM package.

Samples

The package comes with a sample Space game. To import it, use the standard Unity Package Manager UI:

  • Open the package manager through Window -> Package Manager
  • Select "2D Radiance Cascades" from the list
  • Go to the Samples tab and click "Import"

Basic Setup

Adding and Configuring the Renderer Feature

  1. Set up the URP renderer. Both 2D and 3D renderers are supported

  2. Select your Renderer 2D Data (or Universal Renderer Data) asset in your project

  3. In the Inspector, click "Add Renderer Feature" add-render-feature-img

    • (optional) This is where you can tweak the Quality Settings in the inspector of the renderer feature
  4. (optional) In the "General" section of the Renderer 2D change the "Default Material Type" to Custom and assign the RC-Sprite-Lit-Flat material to "Default Custom Material" so your sprites are lit by default.

    • Note: you may need to show hidden packages in the material picker:

      hidden-packages-img

Creating A Lit Scene

  1. Create a new 2D scene
  2. Add light sources and obstacles using either of the options:
    • GameObject -> Radiance Cascades 2D menu
    • manually adding the "Light Contributor" component to an arbitrary GameObject
  3. Add some sprites to your scene
  4. Assign the preconfigured Radiance Cascades/RC-Sprite-Lit-Flat material to the sprites that should be affected by the lighting.
    • If your sprites have normal maps, you may want to use Radiance Cascades/RC-Sprite-Lit-WithNormal material to enable diffuse shading

Demos and Samples

Installation

  1. Open the Unity Package Manager (WindowPackage Manager)
  2. Select the 2D Radiance Cascades package
  3. Go to the Samples tab
  4. Import the sample you're interested in
  5. The assets will appear under Assets/Samples/2D Radiance Cascades/{version}/{demo name} with a scene file at the sample root (if applicable)

demos-img

Preconfigured URP Asset

This sample has a pre-configured URP asset with the Radiance Cascades 2D renderer feature added and set up. You can import it to skip the manual setup.

Note
Importing this sample would automatically assign the included SRP render asset as your default renderer, overriding the previous one.

Examples

A scene featuring different light setups showcasing various package features and usage examples.

Space Demo

A simple Asteroids-like game featuring various features of the lighting system.

The gameplay: Fly around and shoot at asteroids.

Controls:

  • Thrust:
    • Keyboard: Up/Down arrow keys or W/S
    • Gamepad: Right trigger to accelerate, left trigger to decelerate.
  • Rotation:
    • Keyboard: Left/Right arrow keys or A/D
    • Gamepad: Left stick
  • Shoot:
    • Keyboard: Control or Space
    • Gamepad: South action button (A on Xbox controller)

Explore the demo

  1. Check out the light sources:
    • Global lights under the Global Lights game object in the game scene
    • Asteroid debris light source in Prefabs/Debris
    • Bullet in Prefabs/Bullet. Note how an unlit sprite is drawn on top of the light source to preserve the sharp light source shape even when the light map is downscaled
    • The rocket thruster light in the Prefabs/Player prefab under Player/Thruster/Light
  2. Check out the shadow casters:
    • The asteroid in Prefabs/Asteroid
    • The rocket in Prefabs/Player
  3. Check out the light receivers and their materials:
    • The asteroid and the rocket.
      • Note how their sprites have normal maps attached through the standard Unity "Secondary Textures" mechanism.
      • Check out the Materials/SpriteWithNormal.mat material. It uses the package-provided shader for diffuse lighting with normals with the customized distance parameter.
    • The nebula background in Main Camera/Background
      • Note how it uses the lightmap information in a fully custom material with a custom shader.
      • Check out the material shader graph in Materials/Shaders/NebulaBG.shadergraph and the usage of the GetRCLightMapColor node.

Next Steps