Header menu logo Mibo

LightContext2D Type

Central GPU-state holder for 2D lighting. Owns two compiled effects (plain and normal-mapped) loaded from embedded .mgfx resources via ShaderLoader.

Mirrors the raylib LightContext2D. The context collects lights and occluders each frame (via the DirLights/PointLights/OccludersResizeArrays), then uploads them as shader uniforms on the first lit sprite draw. Uniforms are uploaded to both effects so the renderer can switch between plain and normal-mapped per sprite without re-uploading.

The user is responsible for calling Reset() at the start of each frame's view (the renderer does not call it).

Constructors

Constructor Description

LightContext2D(gd, ?litEffect, ?litNormalMapEffect, ?maxDirLights, ?maxPointLights, ?maxOccluders, ?softness, ?maxShadowDistance)

Full Usage: LightContext2D(gd, ?litEffect, ?litNormalMapEffect, ?maxDirLights, ?maxPointLights, ?maxOccluders, ?softness, ?maxShadowDistance)

Parameters:
    gd : GraphicsDevice
    ?litEffect : Effect
    ?litNormalMapEffect : Effect
    ?maxDirLights : int
    ?maxPointLights : int
    ?maxOccluders : int
    ?softness : float32
    ?maxShadowDistance : float32

Returns: LightContext2D
gd : GraphicsDevice
?litEffect : Effect
?litNormalMapEffect : Effect
?maxDirLights : int
?maxPointLights : int
?maxOccluders : int
?softness : float32
?maxShadowDistance : float32
Returns: LightContext2D

Instance members

Instance member Description

this.Ambient

Full Usage: this.Ambient

this.DirLights

Full Usage: this.DirLights

Returns: ResizeArray<DirectionalLight2D>
Returns: ResizeArray<DirectionalLight2D>

this.Effect

Full Usage: this.Effect

Returns: Effect
Returns: Effect

this.EnsureLocationsCached

Full Usage: this.EnsureLocationsCached

Caches shader parameter locations for both effects (idempotent).

this.NormalMapEffect

Full Usage: this.NormalMapEffect

Returns: Effect
Returns: Effect

this.NormalMapParameter

Full Usage: this.NormalMapParameter

Returns: EffectParameter

The normal-map effect's normalMap sampler parameter.

Returns: EffectParameter

this.Occluders

Full Usage: this.Occluders

Returns: ResizeArray<Occluder2D>
Returns: ResizeArray<Occluder2D>

this.PointLights

Full Usage: this.PointLights

Returns: ResizeArray<PointLight2D>
Returns: ResizeArray<PointLight2D>

this.Reset

Full Usage: this.Reset

Clears all lights, occluders, and resets state. Call at the start of each frame's view (the renderer does not call this).

this.ShaderActive

Full Usage: this.ShaderActive

this.ShadowsEnabled

Full Usage: this.ShadowsEnabled

this.UniformsDirty

Full Usage: this.UniformsDirty

this.UploadUniforms

Full Usage: this.UploadUniforms

Uploads all light/occluder uniforms to both effects.

Type something to start searching.