Header menu logo Mibo.Raylib

LightCommands Module

Factory functions for lighting-related render commands. Each function mutates the LightContext2D immediately (during view population) and returns a Command2D for layer ordering.

Functions and values

Function or value Description

addDirectionalLight lightCtx layer light

Full Usage: addDirectionalLight lightCtx layer light

Parameters:
Returns: Command2D
Modifiers: inline

Adds a directional light for the current frame. Mutates the light context immediately. The returned command is a layer placeholder.

lightCtx : LightContext2D
layer : int<MeasureProduct<RenderLayer, MeasureOne>>
light : DirectionalLight2D
Returns: Command2D

addOccluder lightCtx layer occluder

Full Usage: addOccluder lightCtx layer occluder

Parameters:
Returns: Command2D
Modifiers: inline

Adds an occluder segment for the current frame. Used by the shadow system. Mutates the light context immediately. The returned command is a layer placeholder.

lightCtx : LightContext2D
layer : int<MeasureProduct<RenderLayer, MeasureOne>>
occluder : Occluder2D
Returns: Command2D

addPointLight lightCtx layer light

Full Usage: addPointLight lightCtx layer light

Parameters:
Returns: Command2D
Modifiers: inline

Adds a point light for the current frame. Mutates the light context immediately. The returned command is a layer placeholder.

lightCtx : LightContext2D
layer : int<MeasureProduct<RenderLayer, MeasureOne>>
light : PointLight2D
Returns: Command2D

disableShadows lightCtx layer

Full Usage: disableShadows lightCtx layer

Parameters:
Returns: Command2D
Modifiers: inline

Disables shadow raymarching for subsequent lit sprites in this context. Occluders are still collected but not uploaded to the shader. Mutates the light context immediately. The returned command is a layer placeholder.

lightCtx : LightContext2D
layer : int<MeasureProduct<RenderLayer, MeasureOne>>
Returns: Command2D

enableShadows lightCtx layer

Full Usage: enableShadows lightCtx layer

Parameters:
Returns: Command2D
Modifiers: inline

Enables shadow raymarching for subsequent lit sprites in this context. Mutates the light context immediately. The returned command is a layer placeholder.

lightCtx : LightContext2D
layer : int<MeasureProduct<RenderLayer, MeasureOne>>
Returns: Command2D

endLighting lightCtx layer

Full Usage: endLighting lightCtx layer

Parameters:
Returns: Command2D
Modifiers: inline

Ends the current lighting pass. Deactivates the lit shader. Sprites after this point are unlit. Call again to re-enable lighting.

lightCtx : LightContext2D
layer : int<MeasureProduct<RenderLayer, MeasureOne>>
Returns: Command2D

litSprite lightCtx sprite

Full Usage: litSprite lightCtx sprite

Parameters:
Returns: Command2D
Modifiers: inline

Draws a sprite with the current lighting state from the given light context. Activates the lit shader and uploads light uniforms on first call each frame.

lightCtx : LightContext2D
sprite : SpriteState
Returns: Command2D

setAmbient lightCtx (layer, ambient)

Full Usage: setAmbient lightCtx (layer, ambient)

Parameters:
Returns: Command2D
Modifiers: inline

Sets the ambient light color for the current frame. Mutates the light context immediately. The returned command is a layer placeholder. (lightCtx) can be bound first for partial application.

lightCtx : LightContext2D
layer : int<MeasureProduct<RenderLayer, MeasureOne>>
ambient : AmbientLight2D
Returns: Command2D

Type something to start searching.