Used as a base class to create a shadow map.

A Shadow creates a depth Texture (that can vary based on the light type) and a depth comparison Sampler.

Each Mesh added to the Shadow will be rendered beforehand to the depthTexture using a RenderTarget and a custom RenderMaterial.

Hierarchy (view full)

Constructors

Properties

renderer: CameraRenderer

The CameraRenderer used to create this Shadow.

index: number

Index of this Shadow used in the corresponding CameraRenderer shadow buffer binding.

The light that will be used to cast shadows.

options: Omit<ShadowBaseParams, "autoRender">

Options used to create this Shadow.

sampleCount: number

Sample count of the depthTexture. Only 1 is accepted for now.

depthTextureSize: Vec2

Size of the depth Texture to use. Default to Vec2(512).

depthTextureFormat: GPUTextureFormat

Format of the depth Texture to use. Default to depth24plus.

depthTexture: Texture

Depth Texture used to create the shadow map.

depthPassTarget: RenderTarget

Depth RenderTarget onto which the meshes will be rendered.

depthComparisonSampler: Sampler

Depth comparison Sampler used to compare depth in the shaders.

meshes: Map<string, ProjectedMesh>

All the current meshes rendered to the shadow map.

#materials: Map<string, RenderMaterial>

Original meshes materials.

#depthMaterials: Map<string, RenderMaterial>

Corresponding depth meshes materials.

rendererBinding: BufferBinding

CameraRenderer corresponding BufferBinding that holds all the bindings for this type of shadow to send to the shaders.

Accessors

Methods

  • Set the parameters and start casting shadows by setting the isActive setter to true.
    Called internally by the associated Light if any shadow parameters are specified when creating it. Can also be called directly.

    Parameters

    Returns void

  • Render the depth pass. This happens before rendering the scene.

    • Force all the meshes to use their depth materials
    • Render all the meshes
    • Reset all the meshes materials to their original one.

    Parameters

    • once: boolean = false

      Whether to render it only once or not.

    Returns number

  • Render the shadow map only once. Useful with static scenes if autoRender has been set to false to only take one snapshot of the shadow map.

    Returns Promise<void>

  • Add a mesh to the shadow map. Internally called by the mesh if its castShadows parameters has been set to true, but can also be called externally to selectively cast shadows or to add specific parameters (such as custom depth pass shaders).

    Parameters

    Returns void