- Home /
How to clamp lighting values for cel-shading post 5.5?
Previously one could just clamp ndotl to different values in a surface shader but as of unity 5.5 ndotl is updated on the fly and the only way to make these adjustments is to modify the standard shader in the cginc files.
I've followed this tutorial: http://gamedev.stackexchange.com/questions/117747/unity-ignoring-the-deferred-shader
But unfortunately it is not working for me (I also corrected past of the code in the gamedev answer - it was missing a closing parenthesis - which leads me to believe the solution proposed hasn't actually been tested).
I also tried downloading: https://gist.github.com/xDavidLeon/38b392700fbec56162ba But this does not seem to work either.
I emailed David and will update if I get a response. In the meantime, does anyone else know how I could get the desired celshading effect?
Ideally I would like 3 shades based on light distance. So up close would be 100%, 50%, 0% and further away would be 50%, 25%, 0% etc.
Excluding shader code the only way I can think to do this is by adjusting the normals of every object to represent a truncated pyramid/cone (they are all flat sprites so this may be the simplest option). This would give an effect similar to rimlighting but only from a designated angle. This would look ok for stationary lights but moving lights that bypass the characters would look strange and players would quickly identify the structure as the rimlight will always be a fixed size.
If you are using sprites, is it fully necessary to use the Standard shader? The way I would do it would be to use a custom lighting function similar to that of the Standard shader and modify the lighting in there. If not, what you could always do is follow the tutorial normally and make the changes in the .cginc files. If you don't want to override these files for the whole engine, you can copy them into your project's assets and rename both the file and its reference in the shader.
Your answer
Follow this Question
Related Questions
Custom cel shaded Unity shader not casting shadows 1 Answer
Single tone shadows in forward rendering 0 Answers
Weird lighting with cel shader 1 Answer
Build a temporal (unshared) data structure inside a compute shader 0 Answers
Shader error: incorrect number of arguments to numeric-type constructor 2 Answers