Expand description
Voxlap’s world-voxel lighting bake (updatelighting,
voxlap5.c:10539).
Walks every visible voxel inside a 3D bounding box and rewrites
its alpha byte (the per-voxel “brightness” channel that the
rendering path mulhi’es against kv6colmul-style modulators)
based on the engine’s current LightSrc set + lightmode.
Two modes:
lightmode == 1: cheap directional bake — every voxel gets shading from a single hardcoded sun direction(tp.y * 0.5 + tp.z) * 64 + 103.5clamped to[0, 255].lightmode == 2: per-light Lambertian bake — for each light in range, subtractg * h * scwhereg = 1/(d·d²) - 1/(r·r²)(cube-falloff with hard cutoff at radiusr),h = surface_normal · light_delta(negative ⇒ face front- lit, contributes; positive ⇒ self-shadowed, skipped). Result subtracts from a base(tp.y * 0.5 + tp.z) * 16 + 47.5.
The surface normal tp for each voxel comes from estnorm —
a 5×5×5 voxel-solid neighbourhood vote (ESTNORMRAD == 2 in
voxlap, the production path).
Structs§
- EstNorm
Cache - Pre-built
expandbit256grid covering a 2D bounding region —(x1 - x0 + 2*RAD) × (y1 - y0 + 2*RAD)columns. Trades 32 bytes per column of memory for O(1) bit-window lookups during the estnorm 5×5 neighbourhood vote.
Functions§
- apply_
lighting_ with_ cache - S4B.4.b: write half of
update_lighting_chunk, split out so callers can build theEstNormCacheseparately (viaEstNormCache::build_with_reader) and pass it in. - update_
lighting - Bake per-voxel lighting into the world’s brightness bytes.
Mirror of voxlap’s
updatelighting(voxlap5.c:10539). - update_
lighting_ chunk - S4B.4.b: per-chunk variant of
update_lighting.