sphericalPolynomial.d.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. import { Vector3 } from "../Maths/math.vector";
  2. import type { Color3 } from "../Maths/math.color";
  3. /**
  4. * Class representing spherical harmonics coefficients to the 3rd degree
  5. */
  6. export declare class SphericalHarmonics {
  7. /**
  8. * Defines whether or not the harmonics have been prescaled for rendering.
  9. */
  10. preScaled: boolean;
  11. /**
  12. * The l0,0 coefficients of the spherical harmonics
  13. */
  14. l00: Vector3;
  15. /**
  16. * The l1,-1 coefficients of the spherical harmonics
  17. */
  18. l1_1: Vector3;
  19. /**
  20. * The l1,0 coefficients of the spherical harmonics
  21. */
  22. l10: Vector3;
  23. /**
  24. * The l1,1 coefficients of the spherical harmonics
  25. */
  26. l11: Vector3;
  27. /**
  28. * The l2,-2 coefficients of the spherical harmonics
  29. */
  30. l2_2: Vector3;
  31. /**
  32. * The l2,-1 coefficients of the spherical harmonics
  33. */
  34. l2_1: Vector3;
  35. /**
  36. * The l2,0 coefficients of the spherical harmonics
  37. */
  38. l20: Vector3;
  39. /**
  40. * The l2,1 coefficients of the spherical harmonics
  41. */
  42. l21: Vector3;
  43. /**
  44. * The l2,2 coefficients of the spherical harmonics
  45. */
  46. l22: Vector3;
  47. /**
  48. * Adds a light to the spherical harmonics
  49. * @param direction the direction of the light
  50. * @param color the color of the light
  51. * @param deltaSolidAngle the delta solid angle of the light
  52. */
  53. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  54. /**
  55. * Scales the spherical harmonics by the given amount
  56. * @param scale the amount to scale
  57. */
  58. scaleInPlace(scale: number): void;
  59. /**
  60. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  61. *
  62. * ```
  63. * E_lm = A_l * L_lm
  64. * ```
  65. *
  66. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  67. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68. * the scaling factors are given in equation 9.
  69. */
  70. convertIncidentRadianceToIrradiance(): void;
  71. /**
  72. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  73. *
  74. * ```
  75. * L = (1/pi) * E * rho
  76. * ```
  77. *
  78. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  79. */
  80. convertIrradianceToLambertianRadiance(): void;
  81. /**
  82. * Integrates the reconstruction coefficients directly in to the SH preventing further
  83. * required operations at run time.
  84. *
  85. * This is simply done by scaling back the SH with Ylm constants parameter.
  86. * The trigonometric part being applied by the shader at run time.
  87. */
  88. preScaleForRendering(): void;
  89. /**
  90. * update the spherical harmonics coefficients from the given array
  91. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  92. * @returns the spherical harmonics (this)
  93. */
  94. updateFromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  95. /**
  96. * update the spherical harmonics coefficients from the given floats array
  97. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98. * @returns the spherical harmonics (this)
  99. */
  100. updateFromFloatsArray(data: ArrayLike<number>): SphericalHarmonics;
  101. /**
  102. * Constructs a spherical harmonics from an array.
  103. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  104. * @returns the spherical harmonics
  105. */
  106. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  107. /**
  108. * Gets the spherical harmonics from polynomial
  109. * @param polynomial the spherical polynomial
  110. * @returns the spherical harmonics
  111. */
  112. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113. }
  114. /**
  115. * Class representing spherical polynomial coefficients to the 3rd degree
  116. */
  117. export declare class SphericalPolynomial {
  118. private _harmonics;
  119. /**
  120. * The spherical harmonics used to create the polynomials.
  121. */
  122. get preScaledHarmonics(): SphericalHarmonics;
  123. /**
  124. * The x coefficients of the spherical polynomial
  125. */
  126. x: Vector3;
  127. /**
  128. * The y coefficients of the spherical polynomial
  129. */
  130. y: Vector3;
  131. /**
  132. * The z coefficients of the spherical polynomial
  133. */
  134. z: Vector3;
  135. /**
  136. * The xx coefficients of the spherical polynomial
  137. */
  138. xx: Vector3;
  139. /**
  140. * The yy coefficients of the spherical polynomial
  141. */
  142. yy: Vector3;
  143. /**
  144. * The zz coefficients of the spherical polynomial
  145. */
  146. zz: Vector3;
  147. /**
  148. * The xy coefficients of the spherical polynomial
  149. */
  150. xy: Vector3;
  151. /**
  152. * The yz coefficients of the spherical polynomial
  153. */
  154. yz: Vector3;
  155. /**
  156. * The zx coefficients of the spherical polynomial
  157. */
  158. zx: Vector3;
  159. /**
  160. * Adds an ambient color to the spherical polynomial
  161. * @param color the color to add
  162. */
  163. addAmbient(color: Color3): void;
  164. /**
  165. * Scales the spherical polynomial by the given amount
  166. * @param scale the amount to scale
  167. */
  168. scaleInPlace(scale: number): void;
  169. /**
  170. * Updates the spherical polynomial from harmonics
  171. * @param harmonics the spherical harmonics
  172. * @returns the spherical polynomial
  173. */
  174. updateFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  175. /**
  176. * Gets the spherical polynomial from harmonics
  177. * @param harmonics the spherical harmonics
  178. * @returns the spherical polynomial
  179. */
  180. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  181. /**
  182. * Constructs a spherical polynomial from an array.
  183. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  184. * @returns the spherical polynomial
  185. */
  186. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  187. }