LightProbeGrid.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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>Note that this class can only be used with <a href="WebGLRenderer.html">WebGLRenderer</a>.
  18. A version for <a href="WebGPURenderer.html">WebGPURenderer</a> will be added at a later point.</p>
  19. <p>All seven packed SH sub-volumes are stored in a <strong>single</strong> RGBA
  20. <code>WebGL3DRenderTarget</code> using a texture-atlas layout along the Z axis.
  21. Each sub-volume occupies <code>( nz + 2 )</code> atlas slices: one padding slice at
  22. each end (a copy of the nearest edge data slice) to prevent color bleeding
  23. when the hardware trilinear filter reads across a sub-volume boundary.</p>
  24. <p>Atlas layout (nz = resolution.z, PADDING = 1):</p>
  25. <p>Total atlas depth = <code>7 * ( nz + 2 )</code>.</p>
  26. <p>Baking is fully GPU-resident: cubemap rendering, SH projection, and
  27. texture packing all happen on the GPU with zero CPU readback.</p></div>
  28. <h2>Code Example</h2>
  29. <div translate="no"><pre class="prettyprint source"><code> slice 0 : padding (copy of sub-volume 0, data slice 0)
  30. slices 1 … nz : sub-volume 0 data
  31. slice nz + 1 : padding (copy of sub-volume 0, data slice nz-1)
  32. slice nz + 2 : padding (copy of sub-volume 1, data slice 0)
  33. slices nz+3 … 2*nz+2 : sub-volume 1 data
  34. </code></pre></div>
  35. </header>
  36. <article>
  37. <h2 class="subsection-title">Import</h2>
  38. <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>
  39. <pre><code class="language-js">import { LightProbeGrid } from 'three/addons/lighting/LightProbeGrid.js';</code></pre>
  40. <div class="container-overview">
  41. <h2>Constructor</h2>
  42. <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>
  43. <div class="method">
  44. <div class="description">
  45. <p>Constructs a new irradiance probe grid.</p>
  46. <p>The volume is centered at the object's position.</p>
  47. </div>
  48. <table class="params">
  49. <tbody>
  50. <tr>
  51. <td class="name">
  52. <strong translate="no">width</strong>
  53. </td>
  54. <td class="description last">
  55. <p>Full width of the volume along X.</p>
  56. <p>Default is <code>1</code>.</p>
  57. </td>
  58. </tr>
  59. <tr>
  60. <td class="name">
  61. <strong translate="no">height</strong>
  62. </td>
  63. <td class="description last">
  64. <p>Full height of the volume along Y.</p>
  65. <p>Default is <code>1</code>.</p>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td class="name">
  70. <strong translate="no">depth</strong>
  71. </td>
  72. <td class="description last">
  73. <p>Full depth of the volume along Z.</p>
  74. <p>Default is <code>1</code>.</p>
  75. </td>
  76. </tr>
  77. <tr>
  78. <td class="name">
  79. <strong translate="no">widthProbes</strong>
  80. </td>
  81. <td class="description last">
  82. <p>Number of probes along X. Defaults to <code>Math.max( 2, Math.round( width ) + 1 )</code>.</p>
  83. </td>
  84. </tr>
  85. <tr>
  86. <td class="name">
  87. <strong translate="no">heightProbes</strong>
  88. </td>
  89. <td class="description last">
  90. <p>Number of probes along Y. Defaults to <code>Math.max( 2, Math.round( height ) + 1 )</code>.</p>
  91. </td>
  92. </tr>
  93. <tr>
  94. <td class="name">
  95. <strong translate="no">depthProbes</strong>
  96. </td>
  97. <td class="description last">
  98. <p>Number of probes along Z. Defaults to <code>Math.max( 2, Math.round( depth ) + 1 )</code>.</p>
  99. </td>
  100. </tr>
  101. </tbody>
  102. </table>
  103. </div>
  104. </div>
  105. <h2 class="subsection-title">Properties</h2>
  106. <div class="member">
  107. <h3 class="name" id="boundingBox" translate="no">.<a href="#boundingBox">boundingBox</a><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  108. <div class="description">
  109. <p>The world-space bounding box for the grid. Updated automatically
  110. by <a href="LightProbeGrid.html#bake">LightProbeGrid#bake</a>.</p>
  111. </div>
  112. </div>
  113. <div class="member">
  114. <h3 class="name" id="depth" translate="no">.<a href="#depth">depth</a><span class="type-signature"> : number</span> </h3>
  115. <div class="description">
  116. <p>The full depth of the volume along Z.</p>
  117. </div>
  118. </div>
  119. <div class="member">
  120. <h3 class="name" id="height" translate="no">.<a href="#height">height</a><span class="type-signature"> : number</span> </h3>
  121. <div class="description">
  122. <p>The full height of the volume along Y.</p>
  123. </div>
  124. </div>
  125. <div class="member">
  126. <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>
  127. <div class="description">
  128. <p>This flag can be used for type testing.</p>
  129. <p>Default is <code>true</code>.</p>
  130. </div>
  131. </div>
  132. <div class="member">
  133. <h3 class="name" id="resolution" translate="no">.<a href="#resolution">resolution</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  134. <div class="description">
  135. <p>The number of probes along each axis.</p>
  136. </div>
  137. </div>
  138. <div class="member">
  139. <h3 class="name" id="texture" translate="no">.<a href="#texture">texture</a><span class="type-signature"> : <a href="Data3DTexture.html">Data3DTexture</a></span> </h3>
  140. <div class="description">
  141. <p>The single RGBA atlas 3D texture storing all seven packed SH sub-volumes.</p>
  142. <p>Default is <code>null</code>.</p>
  143. </div>
  144. </div>
  145. <div class="member">
  146. <h3 class="name" id="width" translate="no">.<a href="#width">width</a><span class="type-signature"> : number</span> </h3>
  147. <div class="description">
  148. <p>The full width of the volume along X.</p>
  149. </div>
  150. </div>
  151. <h2 class="subsection-title">Methods</h2>
  152. <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>
  153. <div class="method">
  154. <div class="description">
  155. <p>Bakes all probes by rendering cubemaps at each probe position
  156. and projecting to L2 SH. Optionally iterates additional passes to
  157. capture indirect bounces — each extra pass samples the previous pass's
  158. atlas as indirect light, so a grid added to the scene before baking
  159. accumulates one bounce per extra pass.</p>
  160. </div>
  161. <table class="params">
  162. <tbody>
  163. <tr>
  164. <td class="name">
  165. <strong translate="no">renderer</strong>
  166. </td>
  167. <td class="description last">
  168. <p>The renderer.</p>
  169. </td>
  170. </tr>
  171. <tr>
  172. <td class="name">
  173. <strong translate="no">scene</strong>
  174. </td>
  175. <td class="description last">
  176. <p>The scene to render.</p>
  177. </td>
  178. </tr>
  179. <tr>
  180. <td class="name">
  181. <strong translate="no">options</strong>
  182. </td>
  183. <td class="description last">
  184. <p>Bake options.</p>
  185. <table class="params">
  186. <tbody>
  187. <tr>
  188. <td class="name">
  189. <strong translate="no">cubemapSize</strong>
  190. </td>
  191. <td class="description last">
  192. <p>Resolution of each cubemap face.</p>
  193. <p>Default is <code>8</code>.</p>
  194. </td>
  195. </tr>
  196. <tr>
  197. <td class="name">
  198. <strong translate="no">near</strong>
  199. </td>
  200. <td class="description last">
  201. <p>Near plane for the cube camera.</p>
  202. <p>Default is <code>0.1</code>.</p>
  203. </td>
  204. </tr>
  205. <tr>
  206. <td class="name">
  207. <strong translate="no">far</strong>
  208. </td>
  209. <td class="description last">
  210. <p>Far plane for the cube camera.</p>
  211. <p>Default is <code>100</code>.</p>
  212. </td>
  213. </tr>
  214. <tr>
  215. <td class="name">
  216. <strong translate="no">bounces</strong>
  217. </td>
  218. <td class="description last">
  219. <p>Additional bounce passes after the initial direct pass.</p>
  220. <p>Default is <code>0</code>.</p>
  221. </td>
  222. </tr>
  223. </tbody>
  224. </table>
  225. </td>
  226. </tr>
  227. </tbody>
  228. </table>
  229. </div>
  230. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  231. <div class="method">
  232. <div class="description">
  233. <p>Frees GPU resources.</p>
  234. </div>
  235. </div>
  236. <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>
  237. <div class="method">
  238. <div class="description">
  239. <p>Returns the world-space position of the probe at grid indices (ix, iy, iz).</p>
  240. </div>
  241. <table class="params">
  242. <tbody>
  243. <tr>
  244. <td class="name">
  245. <strong translate="no">ix</strong>
  246. </td>
  247. <td class="description last">
  248. <p>X index.</p>
  249. </td>
  250. </tr>
  251. <tr>
  252. <td class="name">
  253. <strong translate="no">iy</strong>
  254. </td>
  255. <td class="description last">
  256. <p>Y index.</p>
  257. </td>
  258. </tr>
  259. <tr>
  260. <td class="name">
  261. <strong translate="no">iz</strong>
  262. </td>
  263. <td class="description last">
  264. <p>Z index.</p>
  265. </td>
  266. </tr>
  267. <tr>
  268. <td class="name">
  269. <strong translate="no">target</strong>
  270. </td>
  271. <td class="description last">
  272. <p>The target vector.</p>
  273. </td>
  274. </tr>
  275. </tbody>
  276. </table>
  277. <dl class="details">
  278. <dt class="tag-returns"><strong>Returns:</strong> The world-space position.</dt>
  279. </dl>
  280. </div>
  281. <h3 class="name name-method" id="updateBoundingBox" translate="no">.<a href="#updateBoundingBox">updateBoundingBox</a><span class="signature">()</span> </h3>
  282. <div class="method">
  283. <div class="description">
  284. <p>Updates the world-space bounding box from the current position and size.</p>
  285. </div>
  286. </div>
  287. <h2 class="subsection-title">Source</h2>
  288. <p>
  289. <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>
  290. </p>
  291. </article>
  292. </section>
  293. <script src="../scripts/linenumber.js"></script>
  294. <script src="../scripts/page.js"></script>
  295. </body>
  296. </html>
粤ICP备19079148号