LightContext2D Type
User-owned mutable context that collects lighting state each frame and uploads it to the GPU when lit sprites render. Shadows use analytic Signed Distance Field (SDF) raymarching in the pixel shader.
Create one in init, store it in your model, call Reset() at the start
of each frame's view, then accumulate lights via LightCommands.setAmbient,
addDirectionalLight, addPointLight, addOccluder,
and draw lit sprites via LightCommands.litSprite.
Occluder line segments are uploaded as a uniform array to the GPU each frame.
Shadow quality is controlled by the softness and maxShadowDistance
parameters. SDF sphere tracing in the pixel shader produces physically-plausible
soft shadows with configurable penumbra — no shadow atlas or extra render
passes required.
Constructors
| Constructor |
Description
|
Full Usage:
LightContext2D(?litShader, ?maxDirLights, ?maxPointLights, ?maxOccluders, ?softness, ?maxShadowDistance)
Parameters:
Shader
?maxDirLights : int
?maxPointLights : int
?maxOccluders : int
?softness : float32
?maxShadowDistance : float32
Returns: LightContext2D
|
|
Instance members
| Instance member |
Description
|
Full Usage:
this.Ambient
|
Current ambient light color. |
|
Directional lights accumulated this frame.
|
|
Occluder segments accumulated this frame.
|
|
Point lights accumulated this frame.
|
Full Usage:
this.Reset
|
Clears accumulated lights, occluders, and resets ambient to black. Call at the start of each frame's view. |
|
The lit-sprite shader (built-in or user-supplied).
|
Full Usage:
this.ShaderActive
|
Whether the lit shader is currently active via BeginShaderMode. Managed by commands. |
Full Usage:
this.ShadowsEnabled
|
Whether shadow raymarching is enabled for this context. Default true. |
Full Usage:
this.UniformsDirty
|
Whether light uniforms need to be re-uploaded to the GPU. |
Full Usage:
this.UploadUniforms
|
Uploads all accumulated light data, occluder segments, and shadow parameters to the GPU. The lit shader must already be active (BeginShaderMode called). |
Mibo.Raylib