Sprite Diffuse Shader

You can use a Sprite Diffuse Shader in Unity to let your 2d sprites be affected by a light. Learn how to create it via Shader Graph, SRP/URP and more!

Sprite Diffuse Shader

In Unity there are multiple ways to create a "Sprite Diffuse Shader" (meaning that sprites are affected by light sources), using both Shader Graph (URP) or HLSL.

Using Shader Graph

URP/SRP

With the addition of the URP (Universal Render Pipeline), or SRP (Scriptable Render Pipeline) you can use the "2D" rendering asset, which already includes a Sprite Diffuse Shader.

LWRP/HDRP

If you're using older versions of Unity, with LWRP or HDRP installed, here's how you can create a Sprite Diffuse Shader. In this tutorial I've used: Lightweight Render Pipeline 2.0.5-preview, Unity 2018.2.0f2.

Here's what we'll achieve:

0:00
/0:12

Diffuse Shader

Here's the shader:

Explanation

In a few words: Sprite Renders need the sprites texture to be called "_MainText".

HLSL

If you want to write a sprite diffuse shader in HLSL, you can go to the Unity Archive and install the built-in shaders for each Unity version.

Febucci

Help us stay independent!

Make sure you never miss other content and help us stay independent and keep posting what we love. It's free! ♥️

Never miss any new post, from games, tools and what we notice in the industry in general
Our Unity, Godot, Game Art and Design learning notes
Help us reach you even if social medias change algorithms, die, AI takes over and suddenly no one knows what's real anymore..
Already have an account? Sign in

Deep dive

Almost five years ago I released a plugin called “Text Animator for Unity”, a tool I made/needed for my own games - and Today it is also getting used in other games like “Dredge, Cult of The Lamb”, “Slime Rancher 2” and many more!! I’d love if you could check it out! you’d also support us with this blog and new assets! ✨

Product callout image

Thanks so much for reading!