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): AreaLightBuffer
import { selectAreaLights } from '@driftengine/core';

Parameters

ParameterTypeDescription
lightsreadonly AreaLightSource[]
outAreaLightBuffer

In depth

Both corrections are here rather than trusted, and neither is defensive tidying:

  • The form factor treats right and up as 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.