Create shadows with Shadow Caster 2D in URP
Light a VFX Graph asset with 2D lights in URP

Create a 2D sprite lit Shader Graph in URP

Create a shaderA program that runs on the GPU. More info
See in Glossary
that reacts to 2D lights when applied to materials.

Create a Sprite Lit Shader Graph

  1. Create a new asset by selecting Assets > Create > Shader Graph > URP > Sprite Lit Shader Graph. The Shader Graph asset is then created in the asset window.

  2. Double-click the new asset to open the Shader Graph.

  3. Create three Sample Texture 2D Nodes by right-clicking on the Shader Graph window and selecting Create Node, then search for and select the Sample Texture 2D option.

  4. Change the Type of one of the Nodes to Normal.

  5. Attach the RGBA(4) Output Slot of the Default Type Nodes as shown below. Note that you should attach the Normal Type Node’s Output Slot to the Normal(Tangent Space)(3) Input Slot.

  6. Create three Texture 2D properties by selecting the + on the Blackboard, and then select Texture 2D. Name them ‘MainTex’, ‘MaskTex’, and ‘NormalMap’ for this example.

  7. Drag each of the Texture 2D properties onto the editor window. Attach each of the properties to the Input Slots of the Sample Texture 2D Nodes as shown below. Note that the ‘NormalMap’ property must be attached to the Normal Type Node only.

  8. Select the NormalMap property, then in the Graph 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
    set Mode to Normal MapA type of Bump Map texture that allows you to add surface detail such as bumps, grooves, and scratches to a model which catch the light as if they are represented by real geometry.
    See in Glossary
    .

  9. If your spriteA 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
    texture has transparency, attach the alpha (A) output of the Base Color texture to the Alpha input of the Fragment context.

  10. Select Save Asset to save the Shader.

You can now apply the newly built Shader to materials.


Did you find this page useful? Please give it a rating:

  • Create shadows with Shadow Caster 2D in URP
    Light a VFX Graph asset with 2D lights in URP