Make a GameObject compatible with 2D lights in URP
Create a 2D light in URP
Add a normal map or a mask map to a sprite in URP
Make a GameObject compatible with 2D lights in URP
Make a shaderA program that runs on the GPU. More info See in Glossary or a visual effect graph compatible with 2D lights 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).
By default, spritesA 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 and tiles you drag into the 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 view use the Sprite-Lit-Default shader, which is already compatible with 2D lights.
To manually set a sprite to use the Sprite-Lit-Default shader, follow these steps:
Select the sprite 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 in the Hierarchy window.
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, in the Sprite RendererA component that lets you display images as Sprites for use in both 2D and 3D scenes. More info See in Glossary component, select the Material picker (⊙).
Select the Sprite-Lit-Default material.
Create a custom shader that reacts to 2D light
To create a custom shader that reacts to 2D lights, use Shader Graph.
Follow these steps:
In the Assets menu, go to Create > Shader Graph > URP > Sprite Lit Shader Graph.
Open the newly created shader graph asset.
Add three Sample Texture 2D nodes to the shader graph.
Set the Type of one of the new nodes to Normal.
Connect the outputs of the nodes to the following Fragment context input slots:
First Default type node: Connect RGBA to Base Color, then connect A to Alpha.
Second Default type node: Connect RGBA to Sprite MaskA texture which defines which areas of an underlying image to reveal or hide. More info See in Glossary.
Normal type node: Connect RGBA to Normal (Tangent Space).
Create three Texture 2D properties by selecting Add (+) on the Blackboard, then choosing Texture 2D:
Main TextureMainTex: Defines the base color and transparency (alpha) of the sprite.
Mask TextureMaskTex: Determines areas of the sprite that should be visible or hidden using a custom mask.
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 GlossaryNormalMap: Adds surface details by simulating bumps and grooves, enhancing lighting effects on the sprite.
Drag each property into the shader graph workspace and connect them to the Texture input slots in the corresponding Sample Texture 2D nodes.
Select Save Asset to save the shader.
A shader graph that enables 2D sprites to react to lighting. Three textures are connected to three Sample Texture 2D nodes. The third node has a type of Normal. The nodes are connected to the inputs of the Fragment context.
You can now apply the shader graph to a material and use it on sprites in a scene, allowing sprites to interact with 2D lights.
Create a visual effect graph that reacts to 2D light
To create a visual effect graph that reacts to 2D light, follow these steps:
In the visual effect graph, replace the Output ParticleA small, simple image or mesh that is emitted by a particle system. A particle system can display and move particles in great numbers to represent a fluid or amorphous entity. The effect of all the particles together creates the impression of the complete entity, such as smoke. More info See in Glossary Unlit node with an Output Particle Shader Graph QuadA primitive object that resembles a plane but its edges are only one unit long, it uses only 4 vertices, and the surface is oriented in the XY plane of the local coordinate space. More info See in Glossary node.
In the Output Particle Shader Graph Quad node, select the Shader Graph picker (⊙).
In the Select Shader Graph Vfx Asset window, select the eye icon to show hidden packages.