Cartoon shader improvements

EDIT: new screenshots showing more clearly what the patch does.

This is for a character builder I’m working on. The hair is procedurally animated using a custom physics simulation (see later post).

Here is an array for visual comparison, in 1:1 size to show artifacts clearly.

Upper left (reference): autoshader toon shading from vanilla 1.8.1
Upper right: smoothing of outlines and light-to-dark transitions enabled
Lower left: specular quantization enabled
Lower right: both smoothing and specular quantization enabled


The outline and light-to-dark transition smoothing options can be controlled separately. Same layout again, but with light-to-dark transition smoothing disabled:


Again, but now all four rendered with light-to-dark transition smoothing enabled:



The parameters are as follows. Lighting:

thresh0=0.55
lev0=0.8
smooth0=0.03
affect_specular=True
thresh0_specular=0.5
lev0_specular=0.8
smooth0_specular=0.03

Inking:

separation=1.2
cutoff=0.5
color=(0,0,0,1.0)
use_advanced_ink=True
blur_amount=0.5
depth_enabled=True