1
0

StorageTextureNode.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>StorageTextureNode - 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. <p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Node.html">Node</a> → <a href="InputNode.html">InputNode</a> → <a href="UniformNode.html">UniformNode</a> → <a href="TextureNode.html">TextureNode</a> → </p>
  13. <h1 translate="no">StorageTextureNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>This special version of a texture node can be used to
  17. write data into a storage texture with a compute shader.</p>
  18. <p>This node can only be used with a WebGPU backend.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">const storageTexture = new THREE.StorageTexture( width, height );
  21. const computeTexture = Fn( ( { storageTexture } ) => {
  22. const posX = instanceIndex.mod( width );
  23. const posY = instanceIndex.div( width );
  24. const indexUV = uvec2( posX, posY );
  25. // generate RGB values
  26. const r = 1;
  27. const g = 1;
  28. const b = 1;
  29. textureStore( storageTexture, indexUV, vec4( r, g, b, 1 ) ).toWriteOnly();
  30. } );
  31. const computeNode = computeTexture( { storageTexture } ).compute( width * height );
  32. renderer.computeAsync( computeNode );
  33. </code></pre></div>
  34. </header>
  35. <article>
  36. <div class="container-overview">
  37. <h2>Constructor</h2>
  38. <h3 class="name name-method" id="StorageTextureNode" translate="no">new <a href="#StorageTextureNode">StorageTextureNode</a><span class="signature">( value : <span class="param-type"><a href="StorageTexture.html">StorageTexture</a></span>, uvNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;(vec2|vec3)></span>, storeNode : <span class="param-type"><a href="Node.html">Node</a></span> )</span> </h3>
  39. <div class="method">
  40. <div class="description">
  41. <p>Constructs a new storage texture node.</p>
  42. </div>
  43. <table class="params">
  44. <tbody>
  45. <tr>
  46. <td class="name">
  47. <strong>value</strong>
  48. </td>
  49. <td class="description last">
  50. <p>The storage texture.</p>
  51. </td>
  52. </tr>
  53. <tr>
  54. <td class="name">
  55. <strong>uvNode</strong>
  56. </td>
  57. <td class="description last">
  58. <p>The uv node.</p>
  59. </td>
  60. </tr>
  61. <tr>
  62. <td class="name">
  63. <strong>storeNode</strong>
  64. </td>
  65. <td class="description last">
  66. <p>The value node that should be stored in the texture.</p>
  67. <p>Default is <code>null</code>.</p>
  68. </td>
  69. </tr>
  70. </tbody>
  71. </table>
  72. </div>
  73. </div>
  74. <h2 class="subsection-title">Properties</h2>
  75. <div class="member">
  76. <h3 class="name" id="access" translate="no">.<a href="#access">access</a><span class="type-signature"> : string</span> </h3>
  77. <div class="description">
  78. <p>The access type of the texture node.</p>
  79. <p>Default is <code>'writeOnly'</code>.</p>
  80. </div>
  81. </div>
  82. <div class="member">
  83. <h3 class="name" id="isStorageTextureNode" translate="no">.<a href="#isStorageTextureNode">isStorageTextureNode</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  84. <div class="description">
  85. <p>This flag can be used for type testing.</p>
  86. <p>Default is <code>true</code>.</p>
  87. </div>
  88. </div>
  89. <div class="member">
  90. <h3 class="name" id="mipLevel" translate="no">.<a href="#mipLevel">mipLevel</a><span class="type-signature"> : number</span> </h3>
  91. <div class="description">
  92. <p>The mip level to write to for storage textures.</p>
  93. <p>Default is <code>0</code>.</p>
  94. </div>
  95. </div>
  96. <div class="member">
  97. <h3 class="name" id="storeNode" translate="no">.<a href="#storeNode">storeNode</a><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  98. <div class="description">
  99. <p>The value node that should be stored in the texture.</p>
  100. <p>Default is <code>null</code>.</p>
  101. </div>
  102. </div>
  103. <h2 class="subsection-title">Methods</h2>
  104. <h3 class="name name-method" id="generate" translate="no">.<a href="#generate">generate</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, output : <span class="param-type">string</span> )</span><span class="type-signature"> : string</span> </h3>
  105. <div class="method">
  106. <div class="description">
  107. <p>Generates the code snippet of the storage node. If no <code>storeNode</code>
  108. is defined, the texture node is generated as normal texture.</p>
  109. </div>
  110. <table class="params">
  111. <tbody>
  112. <tr>
  113. <td class="name">
  114. <strong>builder</strong>
  115. </td>
  116. <td class="description last">
  117. <p>The current node builder.</p>
  118. </td>
  119. </tr>
  120. <tr>
  121. <td class="name">
  122. <strong>output</strong>
  123. </td>
  124. <td class="description last">
  125. <p>The current output.</p>
  126. </td>
  127. </tr>
  128. </tbody>
  129. </table>
  130. <dl class="details">
  131. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TextureNode.html#generate">TextureNode#generate</a></dt>
  132. </dl>
  133. <dl class="details">
  134. <dt class="tag-returns"><strong>Returns:</strong> The generated code snippet.</dt>
  135. </dl>
  136. </div>
  137. <h3 class="name name-method" id="generateStore" translate="no">.<a href="#generateStore">generateStore</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span> </h3>
  138. <div class="method">
  139. <div class="description">
  140. <p>Generates the code snippet of the storage texture node.</p>
  141. </div>
  142. <table class="params">
  143. <tbody>
  144. <tr>
  145. <td class="name">
  146. <strong>builder</strong>
  147. </td>
  148. <td class="description last">
  149. <p>The current node builder.</p>
  150. </td>
  151. </tr>
  152. </tbody>
  153. </table>
  154. </div>
  155. <h3 class="name name-method" id="getInputType" translate="no">.<a href="#getInputType">getInputType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
  156. <div class="method">
  157. <div class="description">
  158. <p>Overwrites the default implementation to return a fixed value <code>'storageTexture'</code>.</p>
  159. </div>
  160. <table class="params">
  161. <tbody>
  162. <tr>
  163. <td class="name">
  164. <strong>builder</strong>
  165. </td>
  166. <td class="description last">
  167. <p>The current node builder.</p>
  168. </td>
  169. </tr>
  170. </tbody>
  171. </table>
  172. <dl class="details">
  173. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TextureNode.html#getInputType">TextureNode#getInputType</a></dt>
  174. </dl>
  175. <dl class="details">
  176. <dt class="tag-returns"><strong>Returns:</strong> The input type.</dt>
  177. </dl>
  178. </div>
  179. <h3 class="name name-method" id="setAccess" translate="no">.<a href="#setAccess">setAccess</a><span class="signature">( value : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="StorageTextureNode.html">StorageTextureNode</a></span> </h3>
  180. <div class="method">
  181. <div class="description">
  182. <p>Defines the node access.</p>
  183. </div>
  184. <table class="params">
  185. <tbody>
  186. <tr>
  187. <td class="name">
  188. <strong>value</strong>
  189. </td>
  190. <td class="description last">
  191. <p>The node access.</p>
  192. </td>
  193. </tr>
  194. </tbody>
  195. </table>
  196. <dl class="details">
  197. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  198. </dl>
  199. </div>
  200. <h3 class="name name-method" id="setMipLevel" translate="no">.<a href="#setMipLevel">setMipLevel</a><span class="signature">( level : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="StorageTextureNode.html">StorageTextureNode</a></span> </h3>
  201. <div class="method">
  202. <div class="description">
  203. <p>Sets the mip level to write to.</p>
  204. </div>
  205. <table class="params">
  206. <tbody>
  207. <tr>
  208. <td class="name">
  209. <strong>level</strong>
  210. </td>
  211. <td class="description last">
  212. <p>The mip level.</p>
  213. </td>
  214. </tr>
  215. </tbody>
  216. </table>
  217. <dl class="details">
  218. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  219. </dl>
  220. </div>
  221. <h3 class="name name-method" id="toReadOnly" translate="no">.<a href="#toReadOnly">toReadOnly</a><span class="signature">()</span><span class="type-signature"> : <a href="StorageTextureNode.html">StorageTextureNode</a></span> </h3>
  222. <div class="method">
  223. <div class="description">
  224. <p>Convenience method for configuring a read-only node access.</p>
  225. </div>
  226. <dl class="details">
  227. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  228. </dl>
  229. </div>
  230. <h3 class="name name-method" id="toReadWrite" translate="no">.<a href="#toReadWrite">toReadWrite</a><span class="signature">()</span><span class="type-signature"> : <a href="StorageTextureNode.html">StorageTextureNode</a></span> </h3>
  231. <div class="method">
  232. <div class="description">
  233. <p>Convenience method for configuring a read/write node access.</p>
  234. </div>
  235. <dl class="details">
  236. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  237. </dl>
  238. </div>
  239. <h3 class="name name-method" id="toWriteOnly" translate="no">.<a href="#toWriteOnly">toWriteOnly</a><span class="signature">()</span><span class="type-signature"> : <a href="StorageTextureNode.html">StorageTextureNode</a></span> </h3>
  240. <div class="method">
  241. <div class="description">
  242. <p>Convenience method for configuring a write-only node access.</p>
  243. </div>
  244. <dl class="details">
  245. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  246. </dl>
  247. </div>
  248. <h2 class="subsection-title">Source</h2>
  249. <p>
  250. <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/accessors/StorageTextureNode.js" translate="no" target="_blank" rel="noopener">src/nodes/accessors/StorageTextureNode.js</a>
  251. </p>
  252. </article>
  253. </section>
  254. <script src="../scripts/linenumber.js"></script>
  255. <script src="../scripts/page.js"></script>
  256. </body>
  257. </html>
粤ICP备19079148号