posterize
Quantizes a continuous color or value (like lighting intensity) into a limited number of discrete levels, used to create non-photorealistic styles like 'posterization' or 'cel-shading'.
Core Advantages
Abstracts the underlying math `floor(color * steps) / steps` into an intention-driven node, allowing developers to think in terms of artistic effects and to programmatically apply the style in real-time to any color source with dynamic control over its intensity.
Common Uses
In cel-shading, to quantize smooth lighting gradients into hard-edged, stepped shadows.
As a post-processing effect to simulate the limited-color style of retro or 8-bit video games.
In data visualization, to clearly divide continuous data (like elevation) into distinct visual tiers, creating contour-like color bands.
Processing normal vectors to create a faceted, low-poly-like shading effect.
How to adjust
The effect is primarily controlled by adjusting the `steps` parameter. A small value (e.g., 2 or 3) produces a high-contrast, blocky appearance. A moderate value (e.g., 5 to 8) creates the classic posterized look. Connecting `steps` to a `timer` or another dynamic node can create animated effects like 'signal interference' or visual 'degradation'.
Code Examples
1// 1. Calculate a smooth lighting factor (0-1)
2const lightFactor = normalWorld.dot( lightDirection ).saturate();
3
4// 2. Core: Quantize the smooth factor into discrete steps
5const posterizedLight = posterize( lightFactor, posterizeSteps );
6
7// 3. Use the stepped lighting result
8output.color = baseColor.mul( posterizedLight );