Builtin Library
README.md
areaLighting
The render feature behind SurfaceLight and
@builtin::systems.areaLights.surfaceLight. One compute pass runs after
lighting, at order 30, adding every registered rectangle's contribution from the
G-buffer.
Diffuse
The exact irradiance of a polygon — Lambert's formula, summing the signed solid angle of each edge as seen from the shaded point. For a quad that is four terms.
Being exact matters where the approximations fail: a wide emitter close to a wall, where treating it as a point puts the falloff in the wrong place entirely.
Specular
The representative point: the spot on the rectangle the reflection ray comes closest to, treated as a point source with the roughness widened to cover the solid angle the rectangle spans.
Widening a lobe spreads the same energy further, so the peak is scaled down by the same factor — without that, a large emitter reads brighter than it is rather than broader.
Falloff
Distance uses a smooth cutoff rather than a hard one, so a surface does not
switch off as it crosses range. The emitter lights only the side its normal
faces.
@scene.material carries the base colour, metallic and roughness. Lighting is summed in
linear radiance and the scene target is decoded and re-encoded around it.
Parameters and lights arrive through the area_light_params and
area_light_records buffers, packed by
@builtin::systems.areaLights.surfaceLight.