Toon / cel shading
Cut the lighting into a few flat bands of color, like a hand-painted animation cel.
Cards
One live example to tweak, learn and copy.
How it works
Ordinary lighting fades smoothly from the lit side of an object to its dark side. Toon shading, also called cel shading, throws that gradient away and keeps only a few flat steps: usually a lit color and a shadow color, sometimes a third band for a highlight. The look comes from hand-drawn animation, where each frame was painted on a clear celluloid sheet with a small set of flat colors.
The math starts where all diffuse lighting starts: the dot productMultiplies two vectors component by component and adds the results. For unit vectors it is the cosine of the angle between them, from 1 (same direction) to -1 (opposite). Dot product Multiplies two vectors component by component and adds the results. For unit vectors it is the cosine of the angle between them, from 1 (same direction) to -1 (opposite). Normal A unit vector perpendicular to a surface, pointing the way it faces. Lighting and Fresnel effects compare it with other directions. Smoothstep A soft threshold. It is 0 below the first edge, 1 above the second, and follows an S-shaped curve with flat ends in between.dot(a, b) = |a| |b| cos θt = clamp((x − e0) / (e1 − e0), 0, 1); s = t² (3 − 2t)
Everything that makes toon shading look designed rather than cheap happens around that threshold: where the shadow line sits, how sharp it is, and what color the shadow gets. A shadow that is the base color times a cool tint keeps its hue, the way an animator would paint it, where a darker gray of the base color looks dirty.
Engines differ a lot here. Godot lets a shader replace its lighting with a light() function, so the bands can react
to every light in the scene. The card below uses one fixed sun inside the shader instead, which works the same on every
platform and is the place to start.
Further reading
- dot (opens in a new tab)Reference
- Dot product (opens in a new tab)Reference
- Basic Lighting (opens in a new tab)Article
- Normal (geometry) (opens in a new tab)Reference
- Normal Mapping (opens in a new tab)Article
- step (opens in a new tab)Reference
- smoothstep (opens in a new tab)Reference
- Shaping functions (opens in a new tab)Book
- Cel shading (opens in a new tab)Reference
- GuiltyGearXrd's Art Style: The X Factor Between 2D and 3D (opens in a new tab)Video