Capítulo 128 de 859

Chapter 128: LightShadow

Core Idea

Abstract base class for light shadow classes. These classes represent the shadow configuration for different light types.

Key Concepts

  • autoUpdate : boolean: Enables automatic updates of the light's shadow. If you do not require dynamic lighting / shadows, you may set this to false.
  • bias : number: Shadow map bias, how much to add or subtract from the normalized depth when deciding whether a surface is in shadow.
  • biasNode : Node.<float>: A node version of bias. Only supported with WebGPURenderer.
  • blurSamples : number: The amount of samples to use when blurring a VSM shadow map.
  • camera : Camera: The light's view of the world.
  • intensity : number: The intensity of the shadow. The default is 1. Valid values are in the range [0, 1].
  • map : RenderTarget: The depth map generated using the internal camera; a location beyond a pixel's depth is in shadow. Computed internally during rendering.
  • mapPass : RenderTarget: The distribution map generated using the internal camera; an occlusion is calculated based on the distribution of depths. Computed internal…
  • mapSize : Vector2: Defines the width and height of the shadow map. Higher values give better quality shadows at the cost of computation time. Values must be p…
  • mapType : number: The type of shadow texture. The default is UnsignedByteType.

Reference Tables

Constructor

Signature
new LightShadow( camera : Camera ) (abstract)

Properties

PropertyDescription
.autoUpdate : booleanEnables automatic updates of the light's shadow. If you do not require dynamic lighting / shadows, you may set this to false.
.bias : numberShadow map bias, how much to add or subtract from the normalized depth when deciding whether a surface is in shadow.
.biasNode : Node.<float>A node version of bias. Only supported with WebGPURenderer.
.blurSamples : numberThe amount of samples to use when blurring a VSM shadow map.
.camera : CameraThe light's view of the world.
.intensity : numberThe intensity of the shadow. The default is 1. Valid values are in the range [0, 1].
.map : RenderTargetThe depth map generated using the internal camera; a location beyond a pixel's depth is in shadow. Computed internally during rendering.
.mapPass : RenderTargetThe distribution map generated using the internal camera; an occlusion is calculated based on the distribution of depths. Computed internally during rendering.
.mapSize : Vector2Defines the width and height of the shadow map. Higher values give better quality shadows at the cost of computation time. Values must be powers of two.
.mapType : numberThe type of shadow texture. The default is UnsignedByteType.
.matrix : Matrix4Model to shadow camera space, to compute location and depth in shadow map. This is computed internally during rendering.
.needsUpdate : booleanWhen set to true, shadow maps will be updated in the next render call. If you have set LightShadow#autoUpdate to false, you will need to set this property to `tru…
.normalBias : numberDefines how much the position used to query the shadow map is offset along the object normal. The default is 0. Increasing this value can be used to reduce shadow acne especially in large scenes wh…
.radius : numberSetting this to values greater than 1 will blur the edges of the shadow. High values will cause unwanted banding effects in the shadows - a greater map size will allow for a higher value to be used h…

Methods

MethodDescription
.clone() : LightShadowReturns a new light shadow instance with copied values from this instance.
.copy( source : LightShadow ) : LightShadowCopies the values of the given light shadow instance to this instance.
.dispose()Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
.getFrameExtents() : Vector2Returns the frame extends.
.getFrustum() : FrustumGets the shadow cameras frustum. Used internally by the renderer to cull objects.
.getViewport( viewportIndex : number ) : Vector4Returns a viewport definition for the given viewport index.
.getViewportCount() : numberUsed internally by the renderer to get the number of viewports that need to be rendered for this shadow.
.toJSON() : ObjectSerializes the light shadow into JSON.
.updateMatrices( light : Light )Update the matrices for the camera and shadow, used internally by the renderer.

Key Takeaways

  1. Most relevant properties: autoUpdate, bias, biasNode, blurSamples.
  2. Key methods: clone, copy, dispose, getFrameExtents.

Connects To