depthRenderer.d.ts 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import type { Nullable } from "../types";
  2. import { Color4 } from "../Maths/math.color";
  3. import type { SubMesh } from "../Meshes/subMesh";
  4. import type { Scene } from "../scene";
  5. import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
  6. import { Camera } from "../Cameras/camera";
  7. import "../Shaders/depth.fragment";
  8. import "../Shaders/depth.vertex";
  9. import type { Material } from "../Materials/material";
  10. import type { AbstractMesh } from "../Meshes/abstractMesh";
  11. /**
  12. * This represents a depth renderer in Babylon.
  13. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  14. */
  15. export declare class DepthRenderer {
  16. private _scene;
  17. private _depthMap;
  18. private readonly _storeNonLinearDepth;
  19. private readonly _storeCameraSpaceZ;
  20. /** Color used to clear the depth texture. Default: (1,0,0,1) */
  21. clearColor: Color4;
  22. /** Get if the depth renderer is using packed depth or not */
  23. readonly isPacked: boolean;
  24. private _camera;
  25. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  26. enabled: boolean;
  27. /** Force writing the transparent objects into the depth map */
  28. forceDepthWriteTransparentMeshes: boolean;
  29. /**
  30. * Specifies that the depth renderer will only be used within
  31. * the camera it is created for.
  32. * This can help forcing its rendering during the camera processing.
  33. */
  34. useOnlyInActiveCamera: boolean;
  35. /** If true, reverse the culling of materials before writing to the depth texture.
  36. * So, basically, when "true", back facing instead of front facing faces are rasterized into the texture
  37. */
  38. reverseCulling: boolean;
  39. /**
  40. * @internal
  41. */
  42. static _SceneComponentInitialization: (scene: Scene) => void;
  43. /**
  44. * Sets a specific material to be used to render a mesh/a list of meshes by the depth renderer
  45. * @param mesh mesh or array of meshes
  46. * @param material material 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.
  47. */
  48. setMaterialForRendering(mesh: AbstractMesh | AbstractMesh[], material?: Material): void;
  49. /**
  50. * Instantiates a depth renderer
  51. * @param scene The scene the renderer belongs to
  52. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  55. * @param samplingMode The sampling mode to be used with the render target (Linear, Nearest...) (default: TRILINEAR_SAMPLINGMODE)
  56. * @param storeCameraSpaceZ Defines whether the depth stored is the Z coordinate in camera space. If true, storeNonLinearDepth has no effect. (Default: false)
  57. * @param name Name of the render target (default: DepthRenderer)
  58. */
  59. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, samplingMode?: number, storeCameraSpaceZ?: boolean, name?: string);
  60. /**
  61. * Creates the depth rendering effect and checks if the effect is ready.
  62. * @param subMesh The submesh to be used to render the depth map of
  63. * @param useInstances If multiple world instances should be used
  64. * @returns if the depth renderer is ready to render the depth map
  65. */
  66. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67. /**
  68. * Gets the texture which the depth map will be written to.
  69. * @returns The depth map texture
  70. */
  71. getDepthMap(): RenderTargetTexture;
  72. /**
  73. * Disposes of the depth renderer.
  74. */
  75. dispose(): void;
  76. }