LightSystem. LightSystemPlugin

LightSystemPlugin

  • Owns the offscreen lightmap texture, falloff/composite shaders, and the per-frame render pass that multiplies the lightmap onto the WebGL scene
  • The composite is MULTIPLICATIVE: unlit areas get the ambient color, lit areas show the scene tinted by the accumulated light color. So you should draw your world at full brightness — the lightmap handles the darkening.

Constructor

new LightSystemPlugin(textureSizeopt, ambientColoropt)

Create the global light system plugin.

Parameters:
NameTypeAttributesDescription
textureSizeVector2<optional>

Size of the lightmap texture (defaults to mainCanvasSize)

ambientColorColor<optional>

Color applied to unlit areas of the scene (defaults to BLACK = pitch dark). Set a small RGB like rgb(0.1,0.1,0.15) for a faint "moonlight" baseline so unlit areas aren't fully black.

Example
// simplest usage
 new LightSystemPlugin();

Members

ambientColor

Properties
TypeDescription
Color

Baseline color applied to unlit areas of the scene. Defaults to BLACK (pitch dark). Set to a small RGB for a faint ambient. The lightmap is cleared to this color each frame, then lights add on top, then the result multiplies the scene.

compositeShader

Properties
TypeDescription
WebGLProgram

Shader for compositing the lightmap over the main scene

compositeVAO

Properties
TypeDescription
WebGLVertexArrayObject

Vertex array object for the composite shader

enabled

Properties
TypeDescription
boolean

When false, the render pass is skipped entirely

lightShader

Properties
TypeDescription
WebGLProgram

Shader for drawing per-Light falloff blobs into the lightmap

lightVAO

Properties
TypeDescription
WebGLVertexArrayObject

Vertex array object for the light shader

texture

Properties
TypeDescription
WebGLTexture

The lightmap texture

textureSize

Properties
TypeDescription
Vector2

Size of the lightmap texture (set at construction; falls back to mainCanvasSize at init time)

Methods

drawLight(light)

Draw a single Light's falloff blob into the currently bound lightmap. Called by Light.renderLight() during the plugin's render pass.

Parameters:
NameTypeDescription
lightLight