Renderer · interface

PointLightBuffer

Explained in Hello world.

interface PointLightBuffer
import type { PointLightBuffer } from '@driftengine/core';

Properties

NameTypeDescription
positionsreadonlyFloat32Array
colorsreadonlyFloat32Array
radiireadonlyFloat32Array
sourceRadiireadonlyFloat32ArrayEach selected light's emitter radius, in metres, packed beside its falloff radius.
More

A light has a size, and a highlight has to know it. The shading treated every source as a mathematical point, so its reflection in a polished surface was a point too: smaller than a fragment, landing in some pixels and not their neighbours. That is the bright speckle a dark glossy model shows under a close lamp, and it cannot be filtered away afterwards because the information was never sampled. A real emitter subtends an angle, and a headlight a few centimetres from a wing subtends a very large one.

sourceRadius already said this and only the shadow pass was listening, which is why the penumbra was right and the highlight was not.

considerednumberHow many sources were offered this frame, against the count that won a slot.
More

Reported from outside, and it turned an afternoon into a glance. A scene was submitting 63 lights against a budget of 10, so the whole budget went to static scenery between 7 and 23 metres away and the rig that answered the music never got a slot. Nothing flickered and nothing warned, because the selection did exactly what it documents; the symptom reported by a person was "the lights are poor", which leads nobody to a light budget. The count had to be recovered by walking the array in a console.

Reading it costs nothing and it is the only figure that makes the ratio visible: 63 offered and 10 bound is a scene to prune, 12 offered and 10 bound is a scene that is fine.

countnumber
sourceIndexreadonlyInt32Array
weightsreadonlyFloat32ArrayHow present each chosen light is, 0 to 1, against the two boundaries it can be crossing: the edge of view range, and the budget cut it shares with the nearest light that missed the set.
More

Deliberately not folded into colors. Most of the shading is a colour multiply and would not care, but the emissive term is not — a lit inlay is dimmed by whichever lamp shadows it hardest, regardless of that lamp's colour, so a light arriving at zero brightness would still switch a shadow onto the start line. The weight has to reach the shader as itself.

directionsreadonlyFloat32ArrayThree per slot: where a spot points, normalised. Zeroes for a point light.
More

Filled for every slot rather than only for spots, because a slot keeps whatever the last light to hold it wrote — and a stale direction on a light that is now a point is a cone pointing somewhere it was never aimed.

coneCosreadonlyFloat32ArrayTwo per slot: the cosine of the inner cone angle, then of the outer.
falloffExponentsreadonlyFloat32ArrayOne per slot: the light's own falloff exponent, or 0 for the frame's falloff. See PointLightSource.falloffExponent.
iesProfilesreadonlyFloat32ArrayOne per slot: a row of the photometric atlas, or −1 for a light with no profile.
scratchDistancereadonlyFloat32ArrayInternal insertion-sort storage; exposed only to keep one flat object.
shadowIndexreadonlyInt32ArrayThe nearest POINT_SHADOW_POOL lights, nearest first — a superset of the shaded ones, and the reason a light no longer pops when it enters the sampled set.
More

Before the shadow pool every light owned a permanent cubemap, so being chosen for shading meant the shadow was already correct. Borrowed maps broke that: joining the set meant evicting somebody and baking six faces at two a frame. The pool has always had four slots more than the shader can bind; these are the lights they are for, kept baked before they are wanted.

shadowCountnumber
completenumberHow far from the selection's centre the choice is complete for DriftLight field lights: a point nearer than this is reached only by field lights chosen at full strength. A field light left out at distance d reaching r first reaches d - r; one dimmed at the cut counts as left out. At most the view range, past which nothing is chosen.