| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>LightProbeGrid - Three.js Docs</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <script src="../scripts/highlight.min.js"></script>
- <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
- <link type="text/css" rel="stylesheet" href="../styles/page.css">
- </head>
- <body>
- <h1 translate="no">LightProbeGrid</h1>
- <section>
- <header>
- <div class="class-description"><p>A 3D grid of L2 Spherical Harmonic irradiance probes that provides
- position-dependent diffuse global illumination.</p>
- <p>All seven packed SH sub-volumes are stored in a <strong>single</strong> RGBA
- <code>WebGL3DRenderTarget</code> using a texture-atlas layout along the Z axis.
- Each sub-volume occupies <code>( nz + 2 )</code> atlas slices: one padding slice at
- each end (a copy of the nearest edge data slice) to prevent color bleeding
- when the hardware trilinear filter reads across a sub-volume boundary.</p>
- <p>Atlas layout (nz = resolution.z, PADDING = 1):</p>
- <p>Total atlas depth = <code>7 * ( nz + 2 )</code>.</p>
- <p>Baking is fully GPU-resident: cubemap rendering, SH projection, and
- texture packing all happen on the GPU with zero CPU readback.</p></div>
- <h2>Code Example</h2>
- <div translate="no"><pre class="prettyprint source"><code> slice 0 : padding (copy of sub-volume 0, data slice 0)
- slices 1 … nz : sub-volume 0 data
- slice nz + 1 : padding (copy of sub-volume 0, data slice nz-1)
- slice nz + 2 : padding (copy of sub-volume 1, data slice 0)
- slices nz+3 … 2*nz+2 : sub-volume 1 data
- …
- </code></pre></div>
- </header>
- <article>
- <h2 class="subsection-title">Import</h2>
- <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>
- <pre><code class="language-js">import { LightProbeGrid } from 'three/addons/lighting/LightProbeGrid.js';</code></pre>
- <div class="container-overview">
- <h2>Constructor</h2>
- <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>
- <div class="method">
- <div class="description">
- <p>Constructs a new irradiance probe grid.</p>
- <p>The volume is centered at the object's position.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong translate="no">width</strong>
- </td>
- <td class="description last">
- <p>Full width of the volume along X.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">height</strong>
- </td>
- <td class="description last">
- <p>Full height of the volume along Y.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">depth</strong>
- </td>
- <td class="description last">
- <p>Full depth of the volume along Z.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">widthProbes</strong>
- </td>
- <td class="description last">
- <p>Number of probes along X. Defaults to <code>Math.max( 2, Math.round( width ) + 1 )</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">heightProbes</strong>
- </td>
- <td class="description last">
- <p>Number of probes along Y. Defaults to <code>Math.max( 2, Math.round( height ) + 1 )</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">depthProbes</strong>
- </td>
- <td class="description last">
- <p>Number of probes along Z. Defaults to <code>Math.max( 2, Math.round( depth ) + 1 )</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <h2 class="subsection-title">Properties</h2>
- <div class="member">
- <h3 class="name" id="boundingBox" translate="no">.<a href="#boundingBox">boundingBox</a><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
- <div class="description">
- <p>The world-space bounding box for the grid. Updated automatically
- by <a href="LightProbeGrid.html#bake">LightProbeGrid#bake</a>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="depth" translate="no">.<a href="#depth">depth</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The full depth of the volume along Z.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="height" translate="no">.<a href="#height">height</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The full height of the volume along Y.</p>
- </div>
- </div>
- <div class="member">
- <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>
- <div class="description">
- <p>This flag can be used for type testing.</p>
- <p>Default is <code>true</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="resolution" translate="no">.<a href="#resolution">resolution</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="description">
- <p>The number of probes along each axis.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="texture" translate="no">.<a href="#texture">texture</a><span class="type-signature"> : <a href="Data3DTexture.html">Data3DTexture</a></span> </h3>
- <div class="description">
- <p>The single RGBA atlas 3D texture storing all seven packed SH sub-volumes.</p>
- <p>Default is <code>null</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="width" translate="no">.<a href="#width">width</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The full width of the volume along X.</p>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <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>
- <div class="method">
- <div class="description">
- <p>Bakes all probes by rendering cubemaps at each probe position
- and projecting to L2 SH. Fully GPU-resident with zero CPU readback.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong translate="no">renderer</strong>
- </td>
- <td class="description last">
- <p>The renderer.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">scene</strong>
- </td>
- <td class="description last">
- <p>The scene to render.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">options</strong>
- </td>
- <td class="description last">
- <p>Bake options.</p>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong translate="no">cubemapSize</strong>
- </td>
- <td class="description last">
- <p>Resolution of each cubemap face.</p>
- <p>Default is <code>8</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">near</strong>
- </td>
- <td class="description last">
- <p>Near plane for the cube camera.</p>
- <p>Default is <code>0.1</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">far</strong>
- </td>
- <td class="description last">
- <p>Far plane for the cube camera.</p>
- <p>Default is <code>100</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Frees GPU resources.</p>
- </div>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Returns the world-space position of the probe at grid indices (ix, iy, iz).</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong translate="no">ix</strong>
- </td>
- <td class="description last">
- <p>X index.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">iy</strong>
- </td>
- <td class="description last">
- <p>Y index.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">iz</strong>
- </td>
- <td class="description last">
- <p>Z index.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">target</strong>
- </td>
- <td class="description last">
- <p>The target vector.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The world-space position.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="updateBoundingBox" translate="no">.<a href="#updateBoundingBox">updateBoundingBox</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Updates the world-space bounding box from the current position and size.</p>
- </div>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <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>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|