Renderer · function
computeLightMatrixForBounds
A directional light's matrix covering a box of known size whole: a model, a level, a room. The
sphere around the box, at its centre, through computeLightMatrix, widened by the half texel the
centre's snap may move it so a corner on the sphere stays inside. Returns the depth span, as that
does.
Explained in Hello world.
function computeLightMatrixForBounds(lightDir: Vec3, min: Readonly<Vec3>, max: Readonly<Vec3>, shadowMapSize: number, out: mat4): numberimport { computeLightMatrixForBounds } from '@driftengine/core';Parameters
| Parameter | Type | Description |
|---|---|---|
lightDir | Vec3 | |
min | Readonly<Vec3> | |
max | Readonly<Vec3> | |
shadowMapSize | number | |
out | mat4 |
In depth
For a scene whose extent is known rather than one that follows a viewer. A radius chosen by
eye around a guessed centre leaves part of the model outside the map, where it casts nothing; the
bounds are the answer, and a loader has them. What it gives up is resolution where the box is
large: the map's texels are spread over all of it, so a building's shadows are coarser than a
focus on the viewer would draw them, which is what computeLightMatrix around the viewer is for.