Expand description
shading — holographic cel lighting model for the Ling renderer.
The look the engine targets is anime / holographic cel: smooth shading over the surface (no faceted triangle edges) but with crisp posterised bands rather than a muddy Gouraud gradient. We get this by:
- lighting each vertex with smooth (averaged) normals — continuous across the mesh,
- interpolating the lit colour across the triangle (done by the rasteriser), then
- posterising per pixel (luminance banded, chroma preserved) so the band boundaries are smooth curves over the surface — the anime line.
On top of diffuse we add:
• coloured lights — each light contributes its own RGB,
• coloured shadows — unlit regions are tinted toward shadow
(a complementary colour) instead of going flat black,
• a Fresnel rim — a view-dependent edge glow for the holographic feel,
• an optional normal-gradient sheen (holo) that shifts hue with the
surface normal, like an iridescent film.
All colours here are linear [f32;3] in 0..1. The renderer converts to
0x00RRGGBB at the end.
Structs§
- LightS
- A coloured point light in world space (mirror of the engine’s
Light). - Shade
Params - Tunable parameters for the cel/holo model.
Functions§
- cel_
ramp - Soft cel ramp for a single diffuse term: keeps smooth shading but gives the lit/shadow transition a gentle “step” so it reads as toon shading even before per-pixel posterisation. Smoothstep around two thresholds.
- lit_
vertex - Light one vertex.
base, result in linear rgb 0..1.n= smooth world normal,pos= world position,eye= camera position. - pack
- Pack linear 0..1 rgb into 0x00RRGGBB.
- posterize
- Posterise a colour into
bandsluminance levels while preserving chroma. This is what turns the smooth interpolated colour into crisp cel bands. - posterize_
soft posterizewith a crossfade back toward the raw colour:softness = 0is a crisp band edge,softness = 1is fully smooth (no banding). Lets a material soften its toon step without reintroducing the per-vertex quantisation that pins band edges to mesh vertices.- unpack
- Unpack 0x00RRGGBB into linear 0..1 rgb.
- windwaker_
cel_ ramp - Wind Waker style 2-band toon diffuse step ramp with crisp shadow threshold.