shadowDepthWrapper.d.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import type { Nullable } from "../types";
  2. import type { Scene } from "../scene";
  3. import type { SubMesh } from "../Meshes/subMesh";
  4. import type { Material } from "./material";
  5. import type { ShadowGenerator } from "../Lights/Shadows/shadowGenerator";
  6. import { DrawWrapper } from "./drawWrapper";
  7. /**
  8. * Options to be used when creating a shadow depth material
  9. */
  10. export interface IIOptionShadowDepthMaterial {
  11. /** Variables in the vertex shader code that need to have their names remapped.
  12. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  13. * "var_name" should be either: worldPos or vNormalW
  14. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  15. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  16. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  17. */
  18. remappedVariables?: string[];
  19. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  20. standalone?: boolean;
  21. /** Set doNotInjectCode if the specific shadow map generation code is already implemented by the material. That will prevent this code to be injected twice by ShadowDepthWrapper */
  22. doNotInjectCode?: boolean;
  23. }
  24. /**
  25. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  26. */
  27. export declare class ShadowDepthWrapper {
  28. private _scene;
  29. private _options?;
  30. private _baseMaterial;
  31. private _onEffectCreatedObserver;
  32. private _subMeshToEffect;
  33. private _subMeshToDepthWrapper;
  34. private _meshes;
  35. /** Gets the standalone status of the wrapper */
  36. get standalone(): boolean;
  37. /** Gets the base material the wrapper is built upon */
  38. get baseMaterial(): Material;
  39. /** Gets the doNotInjectCode status of the wrapper */
  40. get doNotInjectCode(): boolean;
  41. /**
  42. * Instantiate a new shadow depth wrapper.
  43. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  44. * generate the shadow depth map. For more information, please refer to the documentation:
  45. * https://doc.babylonjs.com/features/featuresDeepDive/lights/shadows
  46. * @param baseMaterial Material to wrap
  47. * @param scene Define the scene the material belongs to
  48. * @param options Options used to create the wrapper
  49. */
  50. constructor(baseMaterial: Material, scene?: Scene, options?: IIOptionShadowDepthMaterial);
  51. private _deleteDepthWrapperEffect;
  52. /**
  53. * Gets the effect to use to generate the depth map
  54. * @param subMesh subMesh to get the effect for
  55. * @param shadowGenerator shadow generator to get the effect for
  56. * @param passIdForDrawWrapper Id of the pass for which the effect from the draw wrapper must be retrieved from
  57. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  58. */
  59. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator, passIdForDrawWrapper: number): Nullable<DrawWrapper>;
  60. /**
  61. * Specifies that the submesh is ready to be used for depth rendering
  62. * @param subMesh submesh to check
  63. * @param defines the list of defines to take into account when checking the effect
  64. * @param shadowGenerator combined with subMesh, it defines the effect to check
  65. * @param useInstances specifies that instances should be used
  66. * @param passIdForDrawWrapper Id of the pass for which the draw wrapper should be created
  67. * @returns a boolean indicating that the submesh is ready or not
  68. */
  69. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean, passIdForDrawWrapper: number): boolean;
  70. /**
  71. * Disposes the resources
  72. */
  73. dispose(): void;
  74. private _makeEffect;
  75. }