Renderer · class

LightField

Explained in Hello world.

class LightField implements DriftLightVolumes
import { LightField } from '@driftengine/core';

Constructor

new

constructor(lights: readonly LightFieldSource[], options: LightFieldOptions)
ParameterTypeDescription
lightsreadonly LightFieldSource[]
optionsLightFieldOptions

Properties

NameTypeDescription
layoutreadonlyLightFieldLayout
atlasSizereadonlyreadonly [number, number, number]Texels on each axis of the atlas.
atlasBricksreadonlyreadonly [number, number, number]Bricks on each axis of the atlas, which the shader needs to find a brick's corner.
atlasreadonlyUint16ArrayThe atlas as half floats, four channels a texel, x fastest.
bandreadonlynumberMetres over which exact and summed light crossfade.
occludedreadonlybooleanWhether a distance field occludes this field's light.
fadeSecreadonlynumberSeconds the summed light fades in over once whole; zero is at once.
scalenumberThe summed light's brightness, for a scene that dims all its lamps at once: dawn, a switch.

Accessors

NameTypeDescription
readygetbooleanWhether every brick has been baked.
progressgetnumberHow much of the bake is done, 0 to 1, for a loading screen.
radiusgetnumberThe radius, in metres from centre, inside which lights are shaded exactly.
presencegetnumberHow much of the summed light is in the frame, 0 until the field is whole, then up to 1.
centregetFloat32ArrayWhere the frame's choice was centred, which the shader measures the radius from.
emptygetboolean
indexDimsgetreadonly [number, number, number]
indexgetUint32Array
sampleOrigingetreadonly [number, number, number]
signedSpacinggetnumber

Methods

atlasCorner

atlasCorner(brick: number): [number, number, number]

The texel at which brick brick's light block starts; its direction block is 4 along x.

ParameterTypeDescription
bricknumber

bake

bake(bricks: number): number

Bake up to bricks more bricks into the atlas, and answer how many were baked.

ParameterTypeDescription
bricksnumber

takeBaked

takeBaked(): { from: number; to: number; }

The bricks baked since the last call, for a backend to upload.

follow

follow(complete: number, x: number, y: number, z: number, dtSec: number): void

Follow the frame's choice: complete from the selection, centred at (x, y, z). The radius shrinks at once, because a pixel inside it that a left-out light reaches would be shaded short, and grows back slowly, because a pixel it has not reached yet takes the summed light, which is only less exact. While nothing is summed the radius simply follows.

ParameterTypeDescription
completenumber
xnumber
ynumber
znumber
dtSecnumber