volumetricLightScatteringPostProcess.d.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import { Vector3 } from "../Maths/math.vector";
  2. import { AbstractMesh } from "../Meshes/abstractMesh";
  3. import type { Mesh } from "../Meshes/mesh";
  4. import type { Camera } from "../Cameras/camera";
  5. import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
  6. import { PostProcess } from "./postProcess";
  7. import type { Scene } from "../scene";
  8. import "../Shaders/depth.vertex";
  9. import "../Shaders/volumetricLightScattering.fragment";
  10. import "../Shaders/volumetricLightScatteringPass.vertex";
  11. import "../Shaders/volumetricLightScatteringPass.fragment";
  12. import type { Nullable } from "../types";
  13. import type { AbstractEngine } from "../Engines/abstractEngine";
  14. /**
  15. * Inspired by https://developer.nvidia.com/gpugems/gpugems3/part-ii-light-and-shadows/chapter-13-volumetric-light-scattering-post-process
  16. */
  17. export declare class VolumetricLightScatteringPostProcess extends PostProcess {
  18. private _volumetricLightScatteringRTT;
  19. private _viewPort;
  20. private _screenCoordinates;
  21. /**
  22. * If not undefined, the mesh position is computed from the attached node position
  23. */
  24. attachedNode: {
  25. position: Vector3;
  26. };
  27. /**
  28. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  29. */
  30. customMeshPosition: Vector3;
  31. /**
  32. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  33. */
  34. useCustomMeshPosition: boolean;
  35. /**
  36. * If the post-process should inverse the light scattering direction
  37. */
  38. invert: boolean;
  39. /**
  40. * The internal mesh used by the post-process
  41. */
  42. mesh: Mesh;
  43. /**
  44. * @internal
  45. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  46. */
  47. get useDiffuseColor(): boolean;
  48. set useDiffuseColor(useDiffuseColor: boolean);
  49. /**
  50. * Array containing the excluded meshes not rendered in the internal pass
  51. */
  52. excludedMeshes: AbstractMesh[];
  53. /**
  54. * Array containing the only meshes rendered in the internal pass.
  55. * If this array is not empty, only the meshes from this array are rendered in the internal pass
  56. */
  57. includedMeshes: AbstractMesh[];
  58. /**
  59. * Controls the overall intensity of the post-process
  60. */
  61. exposure: number;
  62. /**
  63. * Dissipates each sample's contribution in range [0, 1]
  64. */
  65. decay: number;
  66. /**
  67. * Controls the overall intensity of each sample
  68. */
  69. weight: number;
  70. /**
  71. * Controls the density of each sample
  72. */
  73. density: number;
  74. /**
  75. * @constructor
  76. * @param name The post-process name
  77. * @param ratio The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  78. * @param camera The camera that the post-process will be attached to
  79. * @param mesh The mesh used to create the light scattering
  80. * @param samples The post-process quality, default 100
  81. * @param samplingMode The post-process filtering mode
  82. * @param engine The babylon engine
  83. * @param reusable If the post-process is reusable
  84. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  85. */
  86. constructor(name: string, ratio: any, camera: Nullable<Camera>, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, scene?: Scene);
  87. /**
  88. * Returns the string "VolumetricLightScatteringPostProcess"
  89. * @returns "VolumetricLightScatteringPostProcess"
  90. */
  91. getClassName(): string;
  92. private _isReady;
  93. /**
  94. * Sets the new light position for light scattering effect
  95. * @param position The new custom light position
  96. */
  97. setCustomMeshPosition(position: Vector3): void;
  98. /**
  99. * Returns the light position for light scattering effect
  100. * @returns Vector3 The custom light position
  101. */
  102. getCustomMeshPosition(): Vector3;
  103. /**
  104. * Disposes the internal assets and detaches the post-process from the camera
  105. * @param camera The camera from which to detach the post-process
  106. */
  107. dispose(camera: Camera): void;
  108. /**
  109. * Returns the render target texture used by the post-process
  110. * @returns the render target texture used by the post-process
  111. */
  112. getPass(): RenderTargetTexture;
  113. private _meshExcluded;
  114. private _createPass;
  115. private _updateMeshScreenCoordinates;
  116. /**
  117. * Creates a default mesh for the Volumeric Light Scattering post-process
  118. * @param name The mesh name
  119. * @param scene The scene where to create the mesh
  120. * @returns the default mesh
  121. */
  122. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  123. }