Toon Shaders with URP and Shader Graph?

I’ve been wracking my brain trying to find a way to make a toon shader with correct shadows in the URP (LWRP in 2019.2.6)

It seems like this simple idea of creating a custom-lit shader should be easy to create, but Shader Graph makes it very complicated.

As a comparison, Amplify Shader Editor makes it very easy to make a custom-lit shader out of the box.

I’d love to start using the URP+ShaderGraph by default, but they lack so many simple features that it doesn’t seem viable at all.

Unity recently released a quick video on this topic, in case you haven’t already seen it:

1 Like

I could be wrong, but that shader still wouldn’t support shadows, right?

All I’m seeing right now are a bunch of hacks to get “almost there” with anything you want to do, but there still isn’t enough functionality to get all the way there. Custom lighting seems to be an example of this.

1 Like

I made a custom master node for URP which supports shadow casting. In fact it allows you to do just about anything, but it purposefully doesn’t much for you. You can see it here: https://github.com/Unity-Technologies/ScriptableRenderPipeline/pull/4912

I’ve managed to get the examples working from Custom Lighting in Shader Graph and Zelda Inspired Toon Shading in Shader Graph blogs to work flawlessly using it. Feel free to give it a whirl.

How to use it? I see PR is closed, how can I manually support this on my local machine?

So what i’ve just done is to open up the Lighting.hlsl file in the pipeline package and do the modifications that are done in shader graph to the ‘LightingPhysicallyBased’ (toon ramp NdotL with smoothstep) and ‘DirectBDRF’ (similar for the specularity) methods.

Essentially updating the lighting model URP is using for their Lit shader.
This way you take advantage of everything the shader has to offer re:lighting,shadows, GI, etc. without having to implement it yourself and its only as expensive as every line you add rather than being on top of the current shader workload which spends the whole time arriving at 0 for each pixel.

It also JustWorks™ for additional lights too and should follow all the settings in the pipeline assets.

Yes you have to read and write the hlsl, but most of the functions and logic you need are identical to those you’ll use in shader graph anyway and its pretty much all in this one file.

if it’s not to much to ask, could make a tutorial on how to do this cause I have know idea

1 Like

Ditto, that would be helpful