Header menu logo Mibo

ShadowConfig Module

Functions and values

Function or value Description

defaults

Full Usage: defaults

Returns: ShadowConfig

Default shadow settings: 1024px, 3 Cascades, 4x4 Atlas (16 slots), 8k Max Texture.

Returns: ShadowConfig

withAtlasTiles n cfg

Full Usage: withAtlasTiles n cfg

Parameters:
Returns: ShadowConfig

Sets the grid size (N x N) of the shadow atlas texture. Determines the total capacity for shadow casting lights (Total Slots = N * N).

n : int
cfg : ShadowConfig
Returns: ShadowConfig

withBias bias normalBias cfg

Full Usage: withBias bias normalBias cfg

Parameters:
Returns: ShadowConfig

Tunable bias values to prevent shadow mapping artifacts. 'bias': Constant depth offset to prevent acne (self-shadowing). 'normalBias': Offset along the geometric normal to cure acne on curved surfaces without inducing Peter-Panning (detached shadows).

bias : float32
normalBias : float32
cfg : ShadowConfig
Returns: ShadowConfig

withCascades n cfg

Full Usage: withCascades n cfg

Parameters:
Returns: ShadowConfig

Sets the number of cascades for directional light shadows (typically 3 or 4). More cascades improve shadow sharpness at various distances but increase the number of draw calls per directional light.

n : int
cfg : ShadowConfig
Returns: ShadowConfig

withMaxAtlasSize n cfg

Full Usage: withMaxAtlasSize n cfg

Parameters:
Returns: ShadowConfig

Sets a hard limit on the shadow atlas texture size in pixels (e.g., 8192). Prevents the system from allocating too much VRAM. If (Resolution * Tiles) exceeds this, individual shadow maps will be downscaled.

n : int
cfg : ShadowConfig
Returns: ShadowConfig

withMaxPointShadows n cfg

Full Usage: withMaxPointShadows n cfg

Parameters:
Returns: ShadowConfig

Sets the maximum number of point lights that can cast shadows. Note: This is largely superseded by 'withAtlasTiles', which determines the total slot capacity.

n : int
cfg : ShadowConfig
Returns: ShadowConfig

withPCFSamples n cfg

Full Usage: withPCFSamples n cfg

Parameters:
Returns: ShadowConfig

Sets the number of PCF samples for soft shadow filtering (e.g., 16). Higher sample counts create smoother soft shadows but are more expensive to compute in the pixel shader.

n : int
cfg : ShadowConfig
Returns: ShadowConfig

withResolution res cfg

Full Usage: withResolution res cfg

Parameters:
Returns: ShadowConfig

Sets the resolution of a single shadow map slice (e.g., 2048). Higher values reduce aliasing (jaggies) but increase VRAM usage and GPU memory bandwidth.

res : int
cfg : ShadowConfig
Returns: ShadowConfig

withSoftShadows penumbra cfg

Full Usage: withSoftShadows penumbra cfg

Parameters:
Returns: ShadowConfig

Enables the soft shadow code path in the shader. 'penumbra' controls the physical size of the light source, determining how blurry the shadows get with distance.

penumbra : float32
cfg : ShadowConfig
Returns: ShadowConfig

Type something to start searching.