Toon shading model for UE 4.20

Hey everyone!

Not sure if it’s worth posting, so mostly I’m looking for a feedback and advices for my code, because I understand literally nothing in shaders and especially in how lighting is working in UE4.
Thanks to the articles from web I’ve found the way to add a new shading model:

http://blog.felixkate.net/2016/05/22/adding-a-custom-shading-model-1/

But awesome Epic guys rewrote a lot in the global shaders for 4.20 so the code from the articles adout shading itself is not suitable for UE versions after 4.19.*.

Since I understand nothing in shaders, I just spent a week trying this and that and each time rebuilding shader by 5-10 min for each recompile.

Anyway, here is the result I’ve pushed to my UE4 fork on the github ( https://github.com/norlin/UnrealEngine/commit/f6469c88ef87c9acf347264afb94e5aa25971511 ).

As you can see, there is a new shading model in the material editor and couple of new pins available.
“Threshold” is a float which defines where to cut lighting (from 0.0 to 1.0) and the “Shadow Intensity” is, well, intensity of the shaded part where 1.0 is the same as fully lit and 0.0 is unlit.

Currently the shader is making 3 areas: “lit”, “shadow” and “intense” – the last one is when the object is under an additional lighting.
I’m not really sure this all made properly, but it’s working.

Would be grateful for any review, advices or feedback!

This toon shading in my own project: Knightmare Lands: toon shading model for UE4.20 - YouTube