Class DepthRenderer
Constructors
constructor
-
new DepthRenderer(
scene: Scene,
type?: number,
camera?: Nullable<Camera>,
storeNonLinearDepth?: boolean,
samplingMode?: number,
storeCameraSpaceZ?: boolean,
name?: string,
existingRenderTargetTexture?: RenderTargetTexture,
): DepthRendererInstantiates a depth renderer
Parameters
- scene: Scene
The scene the renderer belongs to
- type: number = Constants.TEXTURETYPE_FLOAT
The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
- camera: Nullable<Camera> = null
The camera to be used to render the depth map (default: scene's active camera)
- storeNonLinearDepth: boolean = false
Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
- samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE
The sampling mode to be used with the render target (Linear, Nearest...) (default: TRILINEAR_SAMPLINGMODE)
- storeCameraSpaceZ: boolean = false
Defines whether the depth stored is the Z coordinate in camera space. If true, storeNonLinearDepth has no effect. (Default: false)
Optionalname: stringName of the render target (default: DepthRenderer)
OptionalexistingRenderTargetTexture: RenderTargetTextureAn existing render target texture to use (default: undefined). If not provided, a new render target texture will be created.
Returns DepthRenderer
- scene: Scene
Properties
clear Color
Color used to clear the depth texture. Default: (1,0,0,1)
enabled
Enable or disable the depth renderer. When disabled, the depth texture is not updated
force Depth Write Transparent Meshes
Force writing the transparent objects into the depth map
Readonlyis Packed
Get if the depth renderer is using packed depth or not
reverse Culling
If true, reverse the culling of materials before writing to the depth texture. So, basically, when "true", back facing instead of front facing faces are rasterized into the texture
use Only In Active Camera
Specifies that the depth renderer will only be used within the camera it is created for. This can help forcing its rendering during the camera processing.
StaticForce GLSL
Force all the depth renderer to compile to glsl even on WebGPU engines. False by default. This is mostly meant for backward compatibility.
Accessors
alpha Blended Depth
-
get alphaBlendedDepth(): boolean
Enable or disable the alpha blending for depth rendering. When enabled, the depth renderer will blend the depth values with the alpha values of the transparent objects.
Returns boolean
-
set alphaBlendedDepth(value: boolean): void
Parameters
- value: boolean
Returns void
shader Language
-
get shaderLanguage(): ShaderLanguage
Gets the shader language used in this material.
Returns ShaderLanguage
Methods
dispose
-
Disposes of the depth renderer.
Returns void
get Depth Map
-
Gets the texture which the depth map will be written to.
Returns RenderTargetTexture
The depth map texture
is Ready
-
Creates the depth rendering effect and checks if the effect is ready.
Parameters
- subMesh: SubMesh
The submesh to be used to render the depth map of
- useInstances: boolean
If multiple world instances should be used
Returns boolean
if the depth renderer is ready to render the depth map
- subMesh: SubMesh
set Material For Rendering
-
Sets a specific material to be used to render a mesh/a list of meshes by the depth renderer
Parameters
- mesh: AbstractMesh | AbstractMesh[]
mesh or array of meshes
Optionalmaterial: Materialmaterial to use by the depth render when rendering the mesh(es). If undefined is passed, the specific material created by the depth renderer will be used.
Returns void
- mesh: AbstractMesh | AbstractMesh[]
This represents a depth renderer in Babylon. A depth renderer will render to it's depth map every frame which can be displayed or used in post processing