Renderer · function
selectAreaLights
Fill the buffer from a caller's list, normalising the axes and orthogonalising them.
Explained in Hello world.
function selectAreaLights(lights: readonly AreaLightSource[], out: AreaLightBuffer): AreaLightBufferimport { selectAreaLights } from '@driftengine/core';Parameters
| Parameter | Type | Description |
|---|---|---|
lights | readonly AreaLightSource[] | |
out | AreaLightBuffer |
In depth
Both corrections are here rather than trusted, and neither is defensive tidying:
- The form factor treats
rightandupas unit vectors, so a caller's un-normalised axis scales the rectangle it describes. That is a light of the wrong size, which reads as the half extents having been set wrong. - The two axes are made perpendicular, because a rectangle whose axes are not describes a parallelogram — and the form factor is defined for the polygon its four corners make, so what comes out is the irradiance of a shape the caller did not ask for and cannot see the outline of.
Allocation-free: it fills a target the caller owns, because this runs per frame.