Nano WebGPU API - v0.11.0
    Preparing search index...

    Class ShadowSystem

    ShadowSystem coordinates standard orthographic shadow depth map passes for directional lights, spotlight perspective shadow map passes, and Cascaded Shadow Maps (CSM) for directional lights. Handles shadow map resource allocations (depth textures, comparison samplers, uniform buffers), computes orthographic camera matrices aligned with directional vectors, implements texel-snapping to eliminate crawling shadow boundaries, and handles instanced batch drawing.

    Index

    Constructors

    Methods

    • Propagates active PCF filtering settings to standard PBR materials.

      Parameters

      • meshes: readonly Mesh[]

        Active mesh array.

      • usePCF: boolean

        Toggle PCF.

      Returns void

    • Re-allocates shadow depth texture and views if resolution or cascade settings changed. Returns true if new assets were allocated, signaling parent systems to mark bind groups as dirty.

      Parameters

      • newSize: number

        Requested resolution.

      • useCSM: boolean = false

        Toggle CSM mode.

      • cascadeCount: number = 4

        Active cascade layers count.

      Returns boolean

      True if texture was re-created, false otherwise.

    • Renders shadow map depth passes. Calculates camera splits, projects cascades, renders layered textures, or falls back to standard orthographic directional or perspective spotlight depth maps.

      Parameters

      • commandEncoder: GPUCommandEncoder

        GPU command encoder pipeline interface.

      • lights: readonly Light[]

        Current scene lights array.

      • camera: Camera

        Current active viewport camera.

      • batchGroups: Map<string, Mesh[]>

        Grouped meshes sorted by instancing batch keys.

      • instanceBatches: Map<string, InstanceBatch>

        Allocated matrix buffer batches.

      • meshes: readonly Mesh[]

        Active scene meshes array.

      Returns boolean

      True if depth rendering was completed, false otherwise.

    Properties

    bindGroup: GPUBindGroup

    GPUBindGroup mapping shadow uniforms to group 0.

    cascadeCount: number = 4

    Active cascade count for CSM.

    matrix: Mat4 = ...

    Computed combined view-projection matrix from the light source's viewpoint (non-CSM).

    sampler: GPUSampler

    Dedicated comparison sampler checking depth values.

    texture: GPUTexture

    Allocated GPU depth texture (single 2D texture or 2D texture array).

    textureSize: number = 2048

    Resolution size (width/height) of the square shadow map texture. Defaults to 2048.

    uniformBuffer: GPUBuffer

    GPUBuffer containing light view-projection matrices and texel sizes.

    useCSM: boolean = false

    If true, the shadow system is currently utilizing Cascaded Shadow Maps.