Logo Mibo

ShadowAtlasConfig Type

Configuration for the shadow atlas system.

This configuration controls both the atlas texture layout and shadow rendering behavior. Some fields are only used by the forward pipeline implementation. Other pipelines may ignore these fields or use different strategies.

Record fields

Record Field Description

DirectionalAtlasRatio

Full Usage: DirectionalAtlasRatio

Field type: float32

Fraction of the atlas the single directional caster occupies. Default: 0.5.

The directional light is registered first (slot 0) and there is exactly one of it. With a non-zero ratio it gets a dedicated top region of the atlas sized (Resolution × Resolution × ratio) — e.g. 0.5 of an 8192² atlas is 8192×4096 (~4K), instead of the 1/MaxCasters tile the uniform grid would give it. This makes directional shadows high-resolution by default without the user tuning MaxCasters to their scene's light count.

Point/spot casters subdivide the remaining bottom strip (Resolution × (1-ratio)) into a square grid based on their active count. 1.0 gives the directional light the whole atlas (directional-only scenes). 0.0 restores the legacy uniform grid (all casters share 1/MaxCasters tiles — backward compatible).

Field type: float32

DirectionalLightDistance

Full Usage: DirectionalLightDistance

Field type: float32 voption

Distance to place directional light camera behind the shadow origin. Default: 100.

Larger values capture more of the scene but reduce shadow precision. Typical range: 50-200 units.

Field type: float32 voption

DirectionalLightSize

Full Usage: DirectionalLightSize

Field type: float32 voption

Full height of the directional light's orthographic projection, in world units. Default: 50.

Controls the coverage area of directional shadows. Larger values cast shadows over a wider area but reduce resolution. Typical range: 20-100 units. Matches the raylib backend's interpretation (ortho FovY semantics): the same value gives the same coverage and texel density on both backends.

Field type: float32 voption

DirectionalOriginY

Full Usage: DirectionalOriginY

Field type: float32

Fixed world-space Y for the directional shadow frustum origin. Default: 0.

Locking the shadow origin's Y prevents the shadow frustum from sliding vertically when the camera target moves up/down (e.g., the player jumps). Override this if your scene's ground level is not at Y=0.

Field type: float32

GridSnapSize

Full Usage: GridSnapSize

Field type: float32

Grid snap size for shadow origin to reduce flickering. Default: 2.0.

Snaps the shadow origin to a grid to prevent shadow shimmer as the camera moves. Larger values = more stable but less precise shadows. Set to 0 to disable snapping. Typical range: 1.0-5.0 units.

Field type: float32

MaxCasters

Full Usage: MaxCasters

Field type: int

Maximum number of shadow casters. Must be perfect square (4, 9, 16, 25, 36).

Field type: int

OriginStrategy

Full Usage: OriginStrategy

Field type: ShadowOriginStrategy

Strategy for determining shadow map origin. Default: CameraTarget.

Controls where directional light shadows are centered. CameraTarget works well for third-person games where the camera follows a player. SceneCenter works for fixed scenes. Use Custom for first-person or special cases.

Field type: ShadowOriginStrategy

Resolution

Full Usage: Resolution

Field type: int

Resolution of the atlas texture (square). Default 2048.

Field type: int

Type something to start searching.