Create a shadow map from a PointLight by rendering to a depth cube texture using an array of view Mat4 based on the PointLight position and a perspective shadow camera Mat4.

This type of shadow is more expensive than DirectionalShadow since its scene needs to be rendered 6 times to each face of a depth cube texture instead of once.

Hierarchy (view full)

Constructors

Properties

light: PointLight

PointLight associated with this PointShadow.

Perspective shadow camera to use for shadow calculations.

Options used to create this PointShadow.

cubeUps: Vec3[]

Array of Vec3 representing each cube face up directions to compute the .viewMatrices | camera view matrices.

cubeDirections: Vec3[]

Array of Vec3 representing each cube face directions to compute the .viewMatrices | camera view matrices.

#tempCubeDirection: Vec3

Vec3 used to calculate the actual current direction based on the PointLight position.

renderer: CameraRenderer

The CameraRenderer used to create this Shadow.

index: number

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

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

  • get isActive(): boolean
  • Get whether this Shadow is actually casting shadows.

    Returns boolean

    • Whether this Shadow is actually casting shadows.
  • set isActive(value): void
  • Start or stop casting shadows.

    Parameters

    • value: boolean

    Returns void

Methods

  • Render the depth pass. This happens before creating the CameraRenderer command encoder.

    • Force all the meshes to use their depth materials
    • For each face of the depth cube texture:
      • Create a command encoder.
      • Set the depthPassTarget descriptor depth texture view to our depth cube texture current face.
      • Update the face index
      • Render all the meshes
      • Submit the command encoder
    • 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>