Create a custom material for a 2D light
?
Built-in light shader | Custom material with noise |
|---|---|
![]() A spot light that uses the built-in light shader. | ![]() The same spot light with a custom material that adds cloud-like noise to the light. |
Create a Light2D shader graph
- Go to Assets > Create > Shader Graph > URP > Light2D Shader Graph.
- Open the new shader graph. The Fragment context contains the Color, Shadow Color, and Volumetric Color blocks.
- Connect nodes to the blocks to change the light. For more information about each block, refer to Light2D shader graph reference for URP.
- Save the shader graph.
- In the Project window, right-click the shader graph and select Create > Material.
Assign the material to a light
- Select a GameObject that has a Light 2D component.
- In the window, set Material to your new material.Inspector
?
Light 2D component with a custom light material |
|---|
![]() The Light 2D component in the Inspector window, with the Material property highlighted. |
Example: Add noise to a light
- Add a Position node, and set Space to World.
- Connect the Position node to the UV input of a Simple Noise node. Set Scale to 1.5.
- Add 0.2 to the noise result with an Add node, so dark areas aren't fully black.
- Connect the Add node to the Color block.
Shader graph that adds noise to a light |
|---|
![]() A Light2D shader graph. A Position node in world space connects to the UV input of a Simple Noise node with a Scale of 1.5. The noise result and a Float of 0.2 connect to an Add node, which connects to the Color block. |
Change the color of shadows
Shadow Color: black (default) | Shadow Color: blue |
|---|---|
![]() Shadows with the default black Shadow Color. | ![]() The same shadows with a blue Shadow Color. |
Shader graph that makes shadows blue |
|---|
![]() A Light2D shader graph. A Color node set to blue connects to the Shadow Color block. |
Change the color of volumetric light
Volumetric Color: white (default) | Volumetric Color: red, yellow, and green gradient |
|---|---|
![]() A light with the default white volumetric light. | ![]() The same light, with volumetric light that changes from red on the left, through yellow, to green on the right. |
- Add a UV node, and leave Channel set to UV0. For Point, Freeform, and Parametric lights, UV0 goes from 0 to 1 across the area the light covers. For Sprite lights, UV0 is the UV of the sprite.
- Connect the UV node to a Split node.
- Add a Gradient node, and set its colors to red, yellow, and green.
- Connect the Gradient node to the Gradient input of a Sample Gradient node. Connect the R output of the Split node to the Time input.
- Connect the Sample Gradient node to the Volumetric Color block.
Shader graph that colors volumetric light with a gradient |
|---|
![]() A Light2D shader graph. A UV node connects to a Split node. The R output of the Split node and a red, yellow, and green Gradient node connect to a Sample Gradient node, which connects to the Volumetric Color block. |
Troubleshooting
Warning | Solution |
|---|---|
| Use a material that you create from a Light2D shader graph. To use the built-in light shader, clear the Material property. |
| Assign a shader to the material, or clear the Material property. |









