Banded
Banded lighting (also known as cel lighting) quantizes smooth lighting into discrete brightness bands. Instead of a continuous gradient from light to dark, you get distinct “steps”. It’s a common technique in e.g. comic rendering.
It’s one of the simplest yet most effective ways to give 3D objects a hand-painted, non-photorealistic feel.
Visual demo¶
A complete implementation, with detailed comments, is available on Patreon.
// Pseudo-code (Complete implementation, with detailed comments, is available in the related Patreon post)
// Regular Lambertian diffuse term
float NdotL = max(0.0, dot(normal, lightDir));
// Optional offset for better visual balance
float additive = numSteps * (useHalfStep ? 1.0 : 0.5);
// Quantize smooth lighting into discrete bands
float banded = floor((NdotL stepSize + additive) / numSteps) (numSteps / stepSize);
banded = saturate(banded);
// Combine with diffuse term and light color
return banded * diffuseIntensity * lightColor;
Basic idea¶
Banded lighting takes smooth shading (like Lambert) and breaks it into a few flat tones. Commonly applied technique, just like in cartoon or cel-shaded art.
It starts with regular lighting: a dot product (N · L) measures how much the surface faces the light, giving a smooth gradient from bright to dark.
Then the gradient is turned into bands: instead of keeping it smooth, the brightness is “quantized”, rounded down into a few fixed levels.
Dedicated properties control the smoothness: they define how many bands appear and how wide each one is. More steps give a smoother look; fewer steps give bold, stylized shading.
Optionally, a half-step factor shifts the light bands slightly, helping to center them and avoid harsh transitions.
Equation¶
L_banded = floor((max(0, N · L) × s + a) / n) × (n / s)
Where:
- N · L: Lambertian diffuse
- s: lighting step size (smoothness)
- a: additive offset (half-step factor toggle)
- n: number of light bands
This quantized diffuse factor replaces the smooth falloff used in traditional Lambert or Blinn-Phong lighting.
🔗 Related Functions¶
❤️ Support Shader Story¶
If this article helped you, consider supporting the project on Patreon: you’ll get access to the related source files and reference cheat-sheets.
Your support helps keep this library open and free for everyone.