ShadowAtlas Type
Manages a texture atlas for multiple shadow maps. MonoGame port of the canonical
raylib ShadowAtlas.
The atlas is a single square RenderTarget2D
with SurfaceFormat.Single (R32F) —
MonoGame cannot create a sampleable depth-only render target on either backend (depth
buffers are non-sampleable), so the shadow depth is written into the color attachment
via DepthShadow.fx (non-linear position.z to .r). The forward pass
samples it with a comparison sampler (SamplerState.ComparisonFunction) for
hardware PCF — no textureSize or manual 3×3 loop required (SM3.0-clean).
The render target is allocated lazily against the real GraphicsDevice on first
ShadowAtlas.EnsureResources call (mirrors
the B5/B8 lazy-effect pattern) — GraphicsDevice is not available at pipeline
construction time.
Constructors
| Constructor |
Description
|
Full Usage:
ShadowAtlas(config, biasConfig)
Parameters:
ShadowAtlasConfig
biasConfig : ShadowBiasConfig
Returns: ShadowAtlas
|
|
Instance members
| Instance member |
Description
|
Full Usage:
this.ActiveCasterCount
Returns: int
|
Get the number of active caster regions (computed by PrepareUniforms).
|
Full Usage:
this.AddCaster
Parameters:
ShadowCasterType
lightPosition : Vector3
lightDirection : Vector3
lightTarget : Vector3
enabled : bool
biasOverride : float32 voption
Returns: int<MeasureProduct<ShadowCasterId, MeasureOne>> voption
|
Register a new shadow caster and allocate atlas regions. Returns the caster ID, or ValueNone if the atlas is full.
|
|
The bias configuration.
|
Full Usage:
this.Biases
Returns: float32 array
|
|
Full Usage:
this.CasterTypes
Returns: int array
|
|
Full Usage:
this.Casters
Returns: ValueCollection<int<MeasureProduct<ShadowCasterId, MeasureOne>>, ShadowCasterData>
|
Get all active casters (for iteration).
|
Full Usage:
this.Clear
|
Clear all casters and reset slot allocator. Call at start of each frame. |
|
The atlas configuration.
|
Full Usage:
this.Count
Returns: int
|
Number of currently allocated casters.
|
|
Lazily allocate the render target against the real
|
|
The shadow depth render target (R32F color attachment).
|
|
Get bias for a caster type, respecting per-caster override.
|
|
Get the view-projection matrix for a specific atlas region. Returns
|
|
|
|
|
Full Usage:
this.GridSize
Returns: int
|
Grid size (rows/columns) of the atlas.
|
|
|
Full Usage:
this.PrepareUniforms
|
Prepare uniform arrays for upload to the forward shader. Call each frame before uploading shadow uniforms. |
Full Usage:
this.RegionSize
Returns: int
|
Size of each region in pixels.
|
Full Usage:
this.Release
|
Releases the render target. Called from |
|
Remove a shadow caster and free its atlas regions.
|
|
Set the view-projection matrix for a specific atlas region.
|
|
|
|
Get prepared uniform arrays (call after PrepareUniforms).
|
Mibo