1
0

LightProbeGrid.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. Fully GPU-resident with zero CPU readback.</p>
  157. </div>
  158. <table class="params">
  159. <tbody>
  160. <tr>
  161. <td class="name">
  162. <strong translate="no">renderer</strong>
  163. </td>
  164. <td class="description last">
  165. <p>The renderer.</p>
  166. </td>
  167. </tr>
  168. <tr>
  169. <td class="name">
  170. <strong translate="no">scene</strong>
  171. </td>
  172. <td class="description last">
  173. <p>The scene to render.</p>
  174. </td>
  175. </tr>
  176. <tr>
  177. <td class="name">
  178. <strong translate="no">options</strong>
  179. </td>
  180. <td class="description last">
  181. <p>Bake options.</p>
  182. <table class="params">
  183. <tbody>
  184. <tr>
  185. <td class="name">
  186. <strong translate="no">cubemapSize</strong>
  187. </td>
  188. <td class="description last">
  189. <p>Resolution of each cubemap face.</p>
  190. <p>Default is <code>8</code>.</p>
  191. </td>
  192. </tr>
  193. <tr>
  194. <td class="name">
  195. <strong translate="no">near</strong>
  196. </td>
  197. <td class="description last">
  198. <p>Near plane for the cube camera.</p>
  199. <p>Default is <code>0.1</code>.</p>
  200. </td>
  201. </tr>
  202. <tr>
  203. <td class="name">
  204. <strong translate="no">far</strong>
  205. </td>
  206. <td class="description last">
  207. <p>Far plane for the cube camera.</p>
  208. <p>Default is <code>100</code>.</p>
  209. </td>
  210. </tr>
  211. </tbody>
  212. </table>
  213. </td>
  214. </tr>
  215. </tbody>
  216. </table>
  217. </div>
  218. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  219. <div class="method">
  220. <div class="description">
  221. <p>Frees GPU resources.</p>
  222. </div>
  223. </div>
  224. <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>
  225. <div class="method">
  226. <div class="description">
  227. <p>Returns the world-space position of the probe at grid indices (ix, iy, iz).</p>
  228. </div>
  229. <table class="params">
  230. <tbody>
  231. <tr>
  232. <td class="name">
  233. <strong translate="no">ix</strong>
  234. </td>
  235. <td class="description last">
  236. <p>X index.</p>
  237. </td>
  238. </tr>
  239. <tr>
  240. <td class="name">
  241. <strong translate="no">iy</strong>
  242. </td>
  243. <td class="description last">
  244. <p>Y index.</p>
  245. </td>
  246. </tr>
  247. <tr>
  248. <td class="name">
  249. <strong translate="no">iz</strong>
  250. </td>
  251. <td class="description last">
  252. <p>Z index.</p>
  253. </td>
  254. </tr>
  255. <tr>
  256. <td class="name">
  257. <strong translate="no">target</strong>
  258. </td>
  259. <td class="description last">
  260. <p>The target vector.</p>
  261. </td>
  262. </tr>
  263. </tbody>
  264. </table>
  265. <dl class="details">
  266. <dt class="tag-returns"><strong>Returns:</strong> The world-space position.</dt>
  267. </dl>
  268. </div>
  269. <h3 class="name name-method" id="updateBoundingBox" translate="no">.<a href="#updateBoundingBox">updateBoundingBox</a><span class="signature">()</span> </h3>
  270. <div class="method">
  271. <div class="description">
  272. <p>Updates the world-space bounding box from the current position and size.</p>
  273. </div>
  274. </div>
  275. <h2 class="subsection-title">Source</h2>
  276. <p>
  277. <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>
  278. </p>
  279. </article>
  280. </section>
  281. <script src="../scripts/linenumber.js"></script>
  282. <script src="../scripts/page.js"></script>
  283. </body>
  284. </html>
粤ICP备19079148号