LightProbeGrid.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>LightProbeGrid - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <h1 translate="no">LightProbeGrid</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>A 3D grid of L2 Spherical Harmonic irradiance probes that provides
  16. position-dependent diffuse global illumination.</p>
  17. <p>All seven packed SH sub-volumes are stored in a <strong>single</strong> RGBA
  18. <code>WebGL3DRenderTarget</code> using a texture-atlas layout along the Z axis.
  19. Each sub-volume occupies <code>( nz + 2 )</code> atlas slices: one padding slice at
  20. each end (a copy of the nearest edge data slice) to prevent color bleeding
  21. when the hardware trilinear filter reads across a sub-volume boundary.</p>
  22. <p>Atlas layout (nz = resolution.z, PADDING = 1):</p>
  23. <p>Total atlas depth = <code>7 * ( nz + 2 )</code>.</p>
  24. <p>Baking is fully GPU-resident: cubemap rendering, SH projection, and
  25. texture packing all happen on the GPU with zero CPU readback.</p></div>
  26. <h2>Code Example</h2>
  27. <div translate="no"><pre class="prettyprint source"><code> slice 0 : padding (copy of sub-volume 0, data slice 0)
  28. slices 1 … nz : sub-volume 0 data
  29. slice nz + 1 : padding (copy of sub-volume 0, data slice nz-1)
  30. slice nz + 2 : padding (copy of sub-volume 1, data slice 0)
  31. slices nz+3 … 2*nz+2 : sub-volume 1 data
  32. </code></pre></div>
  33. </header>
  34. <article>
  35. <h2 class="subsection-title">Import</h2>
  36. <p><span translate="no">LightProbeGrid</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
  37. <pre><code class="language-js">import { LightProbeGrid } from 'three/addons/lighting/LightProbeGrid.js';</code></pre>
  38. <div class="container-overview">
  39. <h2>Constructor</h2>
  40. <h3 class="name name-method" id="LightProbeGrid" translate="no">new <a href="#LightProbeGrid">LightProbeGrid</a><span class="signature">( width : <span class="param-type">number</span>, height : <span class="param-type">number</span>, depth : <span class="param-type">number</span>, widthProbes : <span class="param-type">number</span>, heightProbes : <span class="param-type">number</span>, depthProbes : <span class="param-type">number</span> )</span> </h3>
  41. <div class="method">
  42. <div class="description">
  43. <p>Constructs a new irradiance probe grid.</p>
  44. <p>The volume is centered at the object's position.</p>
  45. </div>
  46. <table class="params">
  47. <tbody>
  48. <tr>
  49. <td class="name">
  50. <strong translate="no">width</strong>
  51. </td>
  52. <td class="description last">
  53. <p>Full width of the volume along X.</p>
  54. <p>Default is <code>1</code>.</p>
  55. </td>
  56. </tr>
  57. <tr>
  58. <td class="name">
  59. <strong translate="no">height</strong>
  60. </td>
  61. <td class="description last">
  62. <p>Full height of the volume along Y.</p>
  63. <p>Default is <code>1</code>.</p>
  64. </td>
  65. </tr>
  66. <tr>
  67. <td class="name">
  68. <strong translate="no">depth</strong>
  69. </td>
  70. <td class="description last">
  71. <p>Full depth of the volume along Z.</p>
  72. <p>Default is <code>1</code>.</p>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td class="name">
  77. <strong translate="no">widthProbes</strong>
  78. </td>
  79. <td class="description last">
  80. <p>Number of probes along X. Defaults to <code>Math.max( 2, Math.round( width ) + 1 )</code>.</p>
  81. </td>
  82. </tr>
  83. <tr>
  84. <td class="name">
  85. <strong translate="no">heightProbes</strong>
  86. </td>
  87. <td class="description last">
  88. <p>Number of probes along Y. Defaults to <code>Math.max( 2, Math.round( height ) + 1 )</code>.</p>
  89. </td>
  90. </tr>
  91. <tr>
  92. <td class="name">
  93. <strong translate="no">depthProbes</strong>
  94. </td>
  95. <td class="description last">
  96. <p>Number of probes along Z. Defaults to <code>Math.max( 2, Math.round( depth ) + 1 )</code>.</p>
  97. </td>
  98. </tr>
  99. </tbody>
  100. </table>
  101. </div>
  102. </div>
  103. <h2 class="subsection-title">Properties</h2>
  104. <div class="member">
  105. <h3 class="name" id="boundingBox" translate="no">.<a href="#boundingBox">boundingBox</a><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  106. <div class="description">
  107. <p>The world-space bounding box for the grid. Updated automatically
  108. by <a href="LightProbeGrid.html#bake">LightProbeGrid#bake</a>.</p>
  109. </div>
  110. </div>
  111. <div class="member">
  112. <h3 class="name" id="depth" translate="no">.<a href="#depth">depth</a><span class="type-signature"> : number</span> </h3>
  113. <div class="description">
  114. <p>The full depth of the volume along Z.</p>
  115. </div>
  116. </div>
  117. <div class="member">
  118. <h3 class="name" id="height" translate="no">.<a href="#height">height</a><span class="type-signature"> : number</span> </h3>
  119. <div class="description">
  120. <p>The full height of the volume along Y.</p>
  121. </div>
  122. </div>
  123. <div class="member">
  124. <h3 class="name" id="isLightProbeGrid" translate="no">.<a href="#isLightProbeGrid">isLightProbeGrid</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  125. <div class="description">
  126. <p>This flag can be used for type testing.</p>
  127. <p>Default is <code>true</code>.</p>
  128. </div>
  129. </div>
  130. <div class="member">
  131. <h3 class="name" id="resolution" translate="no">.<a href="#resolution">resolution</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  132. <div class="description">
  133. <p>The number of probes along each axis.</p>
  134. </div>
  135. </div>
  136. <div class="member">
  137. <h3 class="name" id="texture" translate="no">.<a href="#texture">texture</a><span class="type-signature"> : <a href="Data3DTexture.html">Data3DTexture</a></span> </h3>
  138. <div class="description">
  139. <p>The single RGBA atlas 3D texture storing all seven packed SH sub-volumes.</p>
  140. <p>Default is <code>null</code>.</p>
  141. </div>
  142. </div>
  143. <div class="member">
  144. <h3 class="name" id="width" translate="no">.<a href="#width">width</a><span class="type-signature"> : number</span> </h3>
  145. <div class="description">
  146. <p>The full width of the volume along X.</p>
  147. </div>
  148. </div>
  149. <h2 class="subsection-title">Methods</h2>
  150. <h3 class="name name-method" id="bake" translate="no">.<a href="#bake">bake</a><span class="signature">( renderer : <span class="param-type"><a href="WebGLRenderer.html">WebGLRenderer</a></span>, scene : <span class="param-type"><a href="Scene.html">Scene</a></span>, options : <span class="param-type">Object</span> )</span> </h3>
  151. <div class="method">
  152. <div class="description">
  153. <p>Bakes all probes by rendering cubemaps at each probe position
  154. and projecting to L2 SH. Fully GPU-resident with zero CPU readback.</p>
  155. </div>
  156. <table class="params">
  157. <tbody>
  158. <tr>
  159. <td class="name">
  160. <strong translate="no">renderer</strong>
  161. </td>
  162. <td class="description last">
  163. <p>The renderer.</p>
  164. </td>
  165. </tr>
  166. <tr>
  167. <td class="name">
  168. <strong translate="no">scene</strong>
  169. </td>
  170. <td class="description last">
  171. <p>The scene to render.</p>
  172. </td>
  173. </tr>
  174. <tr>
  175. <td class="name">
  176. <strong translate="no">options</strong>
  177. </td>
  178. <td class="description last">
  179. <p>Bake options.</p>
  180. <table class="params">
  181. <tbody>
  182. <tr>
  183. <td class="name">
  184. <strong translate="no">cubemapSize</strong>
  185. </td>
  186. <td class="description last">
  187. <p>Resolution of each cubemap face.</p>
  188. <p>Default is <code>8</code>.</p>
  189. </td>
  190. </tr>
  191. <tr>
  192. <td class="name">
  193. <strong translate="no">near</strong>
  194. </td>
  195. <td class="description last">
  196. <p>Near plane for the cube camera.</p>
  197. <p>Default is <code>0.1</code>.</p>
  198. </td>
  199. </tr>
  200. <tr>
  201. <td class="name">
  202. <strong translate="no">far</strong>
  203. </td>
  204. <td class="description last">
  205. <p>Far plane for the cube camera.</p>
  206. <p>Default is <code>100</code>.</p>
  207. </td>
  208. </tr>
  209. </tbody>
  210. </table>
  211. </td>
  212. </tr>
  213. </tbody>
  214. </table>
  215. </div>
  216. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  217. <div class="method">
  218. <div class="description">
  219. <p>Frees GPU resources.</p>
  220. </div>
  221. </div>
  222. <h3 class="name name-method" id="getProbePosition" translate="no">.<a href="#getProbePosition">getProbePosition</a><span class="signature">( ix : <span class="param-type">number</span>, iy : <span class="param-type">number</span>, iz : <span class="param-type">number</span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  223. <div class="method">
  224. <div class="description">
  225. <p>Returns the world-space position of the probe at grid indices (ix, iy, iz).</p>
  226. </div>
  227. <table class="params">
  228. <tbody>
  229. <tr>
  230. <td class="name">
  231. <strong translate="no">ix</strong>
  232. </td>
  233. <td class="description last">
  234. <p>X index.</p>
  235. </td>
  236. </tr>
  237. <tr>
  238. <td class="name">
  239. <strong translate="no">iy</strong>
  240. </td>
  241. <td class="description last">
  242. <p>Y index.</p>
  243. </td>
  244. </tr>
  245. <tr>
  246. <td class="name">
  247. <strong translate="no">iz</strong>
  248. </td>
  249. <td class="description last">
  250. <p>Z index.</p>
  251. </td>
  252. </tr>
  253. <tr>
  254. <td class="name">
  255. <strong translate="no">target</strong>
  256. </td>
  257. <td class="description last">
  258. <p>The target vector.</p>
  259. </td>
  260. </tr>
  261. </tbody>
  262. </table>
  263. <dl class="details">
  264. <dt class="tag-returns"><strong>Returns:</strong> The world-space position.</dt>
  265. </dl>
  266. </div>
  267. <h3 class="name name-method" id="updateBoundingBox" translate="no">.<a href="#updateBoundingBox">updateBoundingBox</a><span class="signature">()</span> </h3>
  268. <div class="method">
  269. <div class="description">
  270. <p>Updates the world-space bounding box from the current position and size.</p>
  271. </div>
  272. </div>
  273. <h2 class="subsection-title">Source</h2>
  274. <p>
  275. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/lighting/LightProbeGrid.js" translate="no" target="_blank" rel="noopener">examples/jsm/lighting/LightProbeGrid.js</a>
  276. </p>
  277. </article>
  278. </section>
  279. <script src="../scripts/linenumber.js"></script>
  280. <script src="../scripts/page.js"></script>
  281. </body>
  282. </html>
粤ICP备19079148号