reflectiveShadowMap.d.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import type { UniformBuffer } from "../Materials/uniformBuffer.js";
  2. import { Matrix } from "../Maths/math.vector.js";
  3. import type { AbstractMesh } from "../Meshes/abstractMesh.js";
  4. import type { Scene } from "../scene.js";
  5. import { MaterialPluginBase } from "../Materials/materialPluginBase.js";
  6. import type { Material } from "../Materials/material.js";
  7. import type { StandardMaterial } from "../Materials/standardMaterial.js";
  8. import { MaterialDefines } from "../Materials/materialDefines.js";
  9. import type { SpotLight } from "../Lights/spotLight.js";
  10. import { PBRBaseMaterial } from "../Materials/PBR/pbrBaseMaterial.js";
  11. import type { DirectionalLight } from "../Lights/directionalLight.js";
  12. /**
  13. * Class used to generate the RSM (Reflective Shadow Map) textures for a given light.
  14. * The textures are: position (in world space), normal (in world space) and flux (light intensity)
  15. */
  16. export declare class ReflectiveShadowMap {
  17. private _scene;
  18. private _light;
  19. private _lightTransformMatrix;
  20. private _mrt;
  21. private _textureDimensions;
  22. private _regularMatToMatWithPlugin;
  23. private _counters;
  24. private _enable;
  25. /**
  26. * Enables or disables the RSM generation.
  27. */
  28. get enable(): boolean;
  29. set enable(value: boolean);
  30. /**
  31. * Gets the position texture generated by the RSM process.
  32. */
  33. get positionWorldTexture(): import("..").Texture;
  34. /**
  35. * Gets the normal texture generated by the RSM process.
  36. */
  37. get normalWorldTexture(): import("..").Texture;
  38. /**
  39. * Gets the flux texture generated by the RSM process.
  40. */
  41. get fluxTexture(): import("..").Texture;
  42. /**
  43. * Gets the render list used to generate the RSM textures.
  44. */
  45. get renderList(): import("..").Nullable<AbstractMesh[]>;
  46. /**
  47. * Gets the light used to generate the RSM textures.
  48. */
  49. get light(): DirectionalLight | SpotLight;
  50. /**
  51. * Gets or sets a boolean indicating if the light parameters should be recomputed even if the light parameters (position, direction) did not change.
  52. * You should not set this value to true, except for debugging purpose (if you want to see changes from the inspector, for eg).
  53. * Instead, you should call updateLightParameters() explicitely at the right time (once the light parameters changed).
  54. */
  55. forceUpdateLightParameters: boolean;
  56. /**
  57. * Creates a new RSM for the given light.
  58. * @param scene The scene
  59. * @param light The light to use to generate the RSM textures
  60. * @param textureDimensions The dimensions of the textures to generate. Default: \{ width: 512, height: 512 \}
  61. */
  62. constructor(scene: Scene, light: DirectionalLight | SpotLight, textureDimensions?: {
  63. width: number;
  64. height: number;
  65. });
  66. /**
  67. * Sets the dimensions of the textures to generate.
  68. * @param dimensions The dimensions of the textures to generate.
  69. */
  70. setTextureDimensions(dimensions: {
  71. width: number;
  72. height: number;
  73. }): void;
  74. /**
  75. * Adds the given mesh to the render list used to generate the RSM textures.
  76. * @param mesh The mesh to add to the render list used to generate the RSM textures. If not provided, all scene meshes will be added to the render list.
  77. */
  78. addMesh(mesh?: AbstractMesh): void;
  79. /**
  80. * Recomputes the light transformation matrix. Call this method if you manually changed the light position / direction / etc. and you want to update the RSM textures accordingly.
  81. * You should also call this method if you add/remove meshes to/from the render list.
  82. */
  83. updateLightParameters(): void;
  84. /**
  85. * Gets the light transformation matrix used to generate the RSM textures.
  86. */
  87. get lightTransformationMatrix(): Matrix;
  88. /**
  89. * Gets the GPU time spent to generate the RSM textures.
  90. */
  91. get countersGPU(): Array<{
  92. name: string;
  93. value: number;
  94. }>;
  95. /**
  96. * Disposes the RSM.
  97. */
  98. dispose(): void;
  99. protected _createMultiRenderTarget(): void;
  100. protected _customRenderTarget(add: boolean): void;
  101. protected _recomputeLightTransformationMatrix(): void;
  102. protected _addMeshToMRT(mesh: AbstractMesh): void;
  103. protected _disposeMultiRenderTarget(): void;
  104. }
  105. /**
  106. * @internal
  107. */
  108. declare class MaterialRSMCreateDefines extends MaterialDefines {
  109. RSMCREATE: boolean;
  110. RSMCREATE_PROJTEXTURE: boolean;
  111. RSMCREATE_LIGHT_IS_SPOT: boolean;
  112. }
  113. /**
  114. * Plugin that implements the creation of the RSM textures
  115. */
  116. export declare class RSMCreatePluginMaterial extends MaterialPluginBase {
  117. private _varAlbedoName;
  118. private _lightColor;
  119. private _hasProjectionTexture;
  120. /**
  121. * Defines the name of the plugin.
  122. */
  123. static readonly Name = "RSMCreate";
  124. /**
  125. * Defines the light that should be used to generate the RSM textures.
  126. */
  127. light: DirectionalLight | SpotLight;
  128. private _isEnabled;
  129. /**
  130. * Defines if the plugin is enabled in the material.
  131. */
  132. isEnabled: boolean;
  133. protected _markAllSubMeshesAsTexturesDirty(): void;
  134. private _internalMarkAllSubMeshesAsTexturesDirty;
  135. /**
  136. * Create a new RSMCreatePluginMaterial
  137. * @param material Parent material of the plugin
  138. */
  139. constructor(material: Material | StandardMaterial | PBRBaseMaterial);
  140. prepareDefines(defines: MaterialRSMCreateDefines): void;
  141. getClassName(): string;
  142. getUniforms(): {
  143. ubo: {
  144. name: string;
  145. size: number;
  146. type: string;
  147. }[];
  148. fragment: string;
  149. };
  150. getSamplers(samplers: string[]): void;
  151. bindForSubMesh(uniformBuffer: UniformBuffer): void;
  152. getCustomCode(shaderType: string): {
  153. CUSTOM_FRAGMENT_BEGIN: string;
  154. CUSTOM_FRAGMENT_DEFINITIONS: string;
  155. CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: string;
  156. } | null;
  157. }
  158. export {};