Hi!
I’ve been messing around with ShaderLab and ShaderGraph, trying to make a 2D Cell/Toon Shader, that replicate the one in Laigter. (awesome software btw)
Where I’m at:
Currently I have a working hlsl shader, that with a few alterations using the unity template, I was able to render the effect with some wild, but good results.
The code below is a snippet of what I am doing in the fragment shader responsible for the normal map:
Objective:
Now I was hoping to be able to do the same effect in shader graph, mostly for iteration reasons.
Shortly, I am looking for this using 2D lights (and without fresnel). aka this
For what I understand the custom node in the 6 above (see below) doesn’t work for 2D lights, I was wondering if there’s is a replacement function for GetMainLight(0) or something.
#ifndef CUSTOM_LIGHTING_INCLUDED
#define CUSTOM_LIGHTING_INCLUDED
void CalculateMainLight_float(float3 WorldPos, out float3 Direction, out float3 Color)
{
#if defined(SHADERGRAPH_PREVIEW)
Direction = float3(0.5, 0.5, 0);
Color = 1;
#else
Light mainLight = GetMainLight(0);
Direction = -mainLight.direction;
Color = mainLight.color;
#endif
}
#endif
I will also leave some links that were useful during my research:
- Toon Shading for 2D Sprites v1 - Godot Shaders
- https://www.youtube.com/watch?v=gY1Mx4kkZPU&t=300s
- Writing a SpriteLamp Shader in Unity | Indreams Studios
Thanks! ![]()

