- Home /
Cell Shading Using 2D Renderer?
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 link 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:
https://godotshaders.com/shader/cel-toon-shading-for-2d-sprites/
http://indreams-studios.com/post/writing-a-spritelamp-shader-in-unity/
Thanks! :D
Your answer
Follow this Question
Related Questions
Set list in shader (uniform) 1 Answer
How can I add Color property To This Shader 1 Answer
ShaderLab on Unity3d Indie 2 Answers
Mathf.Repeat in ShaderLab? 1 Answer