subSurfaceConfiguration.d.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import type { Scene } from "../scene";
  2. import { Color3 } from "../Maths/math.color";
  3. import { SubSurfaceScatteringPostProcess } from "../PostProcesses/subSurfaceScatteringPostProcess";
  4. import type { PrePassEffectConfiguration } from "./prePassEffectConfiguration";
  5. /**
  6. * Contains all parameters needed for the prepass to perform
  7. * screen space subsurface scattering
  8. */
  9. export declare class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  10. /**
  11. * @internal
  12. */
  13. static _SceneComponentInitialization: (scene: Scene) => void;
  14. private _ssDiffusionS;
  15. private _ssFilterRadii;
  16. private _ssDiffusionD;
  17. /**
  18. * Post process to attach for screen space subsurface scattering
  19. */
  20. postProcess: SubSurfaceScatteringPostProcess;
  21. /**
  22. * Diffusion profile color for subsurface scattering
  23. */
  24. get ssDiffusionS(): number[];
  25. /**
  26. * Diffusion profile max color channel value for subsurface scattering
  27. */
  28. get ssDiffusionD(): number[];
  29. /**
  30. * Diffusion profile filter radius for subsurface scattering
  31. */
  32. get ssFilterRadii(): number[];
  33. /**
  34. * Is subsurface enabled
  35. */
  36. enabled: boolean;
  37. /**
  38. * Does the output of this prepass need to go through imageprocessing
  39. */
  40. needsImageProcessing: boolean;
  41. /**
  42. * Name of the configuration
  43. */
  44. name: string;
  45. /**
  46. * Diffusion profile colors for subsurface scattering
  47. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  48. * See ...
  49. * Note that you can only store up to 5 of them
  50. */
  51. ssDiffusionProfileColors: Color3[];
  52. /**
  53. * Defines the ratio real world => scene units.
  54. * Used for subsurface scattering
  55. */
  56. metersPerUnit: number;
  57. /**
  58. * Textures that should be present in the MRT for this effect to work
  59. */
  60. readonly texturesRequired: number[];
  61. private _scene;
  62. /**
  63. * Builds a subsurface configuration object
  64. * @param scene The scene
  65. */
  66. constructor(scene: Scene);
  67. /**
  68. * Adds a new diffusion profile.
  69. * Useful for more realistic subsurface scattering on diverse materials.
  70. * @param color The color of the diffusion profile. Should be the average color of the material.
  71. * @returns The index of the diffusion profile for the material subsurface configuration
  72. */
  73. addDiffusionProfile(color: Color3): number;
  74. /**
  75. * Creates the sss post process
  76. * @returns The created post process
  77. */
  78. createPostProcess(): SubSurfaceScatteringPostProcess;
  79. /**
  80. * Deletes all diffusion profiles.
  81. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  82. */
  83. clearAllDiffusionProfiles(): void;
  84. /**
  85. * Disposes this object
  86. */
  87. dispose(): void;
  88. /**
  89. * @internal
  90. * https://zero-radiance.github.io/post/sampling-diffusion/
  91. *
  92. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  93. * ------------------------------------------------------------------------------------
  94. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  95. * PDF[r, phi, s] = r * R[r, phi, s]
  96. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  97. * ------------------------------------------------------------------------------------
  98. * We importance sample the color channel with the widest scattering distance.
  99. */
  100. getDiffusionProfileParameters(color: Color3): number;
  101. /**
  102. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  103. * 'u' is the random number (the value of the CDF): [0, 1).
  104. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  105. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  106. * @param u
  107. * @param rcpS
  108. * @returns The sampled radial distance
  109. */
  110. private _sampleBurleyDiffusionProfile;
  111. }