Add-ons and more

A Toon OSL shader for Blender

A question on Blender Artists made me think about a toon shader. There are of course many ways to implment toon shaders but here is what I came up with.

The basic idea of this shader is to determine how perpendicular the surface of an object is compared to the viewing angle and return black instead of the regular color if some threshold is passed. That is exactly what line 8 does in the code below.
shader outline(
    color Color = 1,
    float Angle = 50,
    output color Cout = 0
)
{
    float angle = cos(radians(Angle));
    if(abs(dot(-I,N)) > angle) Cout = Color;
}

Example node setup

The noodle used to create the sample image of Suzanne looks like this:

No comments:

Post a Comment