GTAONode.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>GTAONode - 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="TempNode.html">TempNode</a> → </p>
  13. <h1 translate="no">GTAONode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Post processing node for applying Ground Truth Ambient Occlusion (GTAO) to a scene.</p>
  17. <p>Reference: <a href="https://www.activision.com/cdn/research/Practical_Real_Time_Strategies_for_Accurate_Indirect_Occlusion_NEW%2520VERSION_COLOR.pdf" target="_blank" rel="noopener">https://www.activision.com/cdn/research/Practical_Real_Time_Strategies_for_Accurate_Indirect_Occlusion_NEW%20VERSION_COLOR.pdf</a>.</p></div>
  18. <h2>Code Example</h2>
  19. <div translate="no"><pre><code class="language-js">const postProcessing = new THREE.PostProcessing( renderer );
  20. const scenePass = pass( scene, camera );
  21. scenePass.setMRT( mrt( {
  22. output: output,
  23. normal: normalView
  24. } ) );
  25. const scenePassColor = scenePass.getTextureNode( 'output' );
  26. const scenePassNormal = scenePass.getTextureNode( 'normal' );
  27. const scenePassDepth = scenePass.getTextureNode( 'depth' );
  28. const aoPass = ao( scenePassDepth, scenePassNormal, camera );
  29. postProcessing.outputNod = aoPass.getTextureNode().mul( scenePassColor );
  30. </code></pre></div>
  31. </header>
  32. <article>
  33. <h2 class="subsection-title">Import</h2>
  34. <p><span translate="no">GTAONode</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>
  35. <pre><code class="language-js">import { ao } from 'three/addons/tsl/display/GTAONode.js';</code></pre>
  36. <div class="container-overview">
  37. <h2>Constructor</h2>
  38. <h3 class="name name-method" id="GTAONode" translate="no">new <a href="#GTAONode">GTAONode</a><span class="signature">( depthNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;float></span>, normalNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;vec3></span>, camera : <span class="param-type"><a href="Camera.html">Camera</a></span> )</span> </h3>
  39. <div class="method">
  40. <div class="description">
  41. <p>Constructs a new GTAO node.</p>
  42. </div>
  43. <table class="params">
  44. <tbody>
  45. <tr>
  46. <td class="name">
  47. <strong>depthNode</strong>
  48. </td>
  49. <td class="description last">
  50. <p>A node that represents the scene's depth.</p>
  51. </td>
  52. </tr>
  53. <tr>
  54. <td class="name">
  55. <strong>normalNode</strong>
  56. </td>
  57. <td class="description last">
  58. <p>A node that represents the scene's normals.</p>
  59. </td>
  60. </tr>
  61. <tr>
  62. <td class="name">
  63. <strong>camera</strong>
  64. </td>
  65. <td class="description last">
  66. <p>The camera the scene is rendered with.</p>
  67. </td>
  68. </tr>
  69. </tbody>
  70. </table>
  71. </div>
  72. </div>
  73. <h2 class="subsection-title">Properties</h2>
  74. <div class="member">
  75. <h3 class="name" id="depthNode" translate="no">.<a href="#depthNode">depthNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  76. <div class="description">
  77. <p>A node that represents the scene's depth.</p>
  78. </div>
  79. </div>
  80. <div class="member">
  81. <h3 class="name" id="distanceExponent" translate="no">.<a href="#distanceExponent">distanceExponent</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  82. <div class="description">
  83. <p>Another option to tweak the occlusion. The recommended range is
  84. <code>[1,2]</code> for attenuating the AO.</p>
  85. </div>
  86. </div>
  87. <div class="member">
  88. <h3 class="name" id="distanceFallOff" translate="no">.<a href="#distanceFallOff">distanceFallOff</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  89. <div class="description">
  90. <p>The distance fall off value of the ambient occlusion.
  91. A lower value leads to a larger AO effect. The value
  92. should lie in the range <code>[0,1]</code>.</p>
  93. </div>
  94. </div>
  95. <div class="member">
  96. <h3 class="name" id="normalNode" translate="no">.<a href="#normalNode">normalNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  97. <div class="description">
  98. <p>A node that represents the scene's normals. If no normals are passed to the
  99. constructor (because MRT is not available), normals can be automatically
  100. reconstructed from depth values in the shader.</p>
  101. </div>
  102. </div>
  103. <div class="member">
  104. <h3 class="name" id="radius" translate="no">.<a href="#radius">radius</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  105. <div class="description">
  106. <p>The radius of the ambient occlusion.</p>
  107. </div>
  108. </div>
  109. <div class="member">
  110. <h3 class="name" id="resolution" translate="no">.<a href="#resolution">resolution</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;vec2></span> </h3>
  111. <div class="description">
  112. <p>The resolution of the effect. Can be scaled via
  113. <code>resolutionScale</code>.</p>
  114. </div>
  115. </div>
  116. <div class="member">
  117. <h3 class="name" id="resolutionScale" translate="no">.<a href="#resolutionScale">resolutionScale</a><span class="type-signature"> : number</span> </h3>
  118. <div class="description">
  119. <p>The resolution scale. By default the effect is rendered in full resolution
  120. for best quality but a value of <code>0.5</code> should be sufficient for most scenes.</p>
  121. <p>Default is <code>1</code>.</p>
  122. </div>
  123. </div>
  124. <div class="member">
  125. <h3 class="name" id="samples" translate="no">.<a href="#samples">samples</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  126. <div class="description">
  127. <p>How many samples are used to compute the AO.
  128. A higher value results in better quality but also
  129. in a more expensive runtime behavior.</p>
  130. </div>
  131. </div>
  132. <div class="member">
  133. <h3 class="name" id="scale" translate="no">.<a href="#scale">scale</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  134. <div class="description">
  135. <p>The scale of the ambient occlusion.</p>
  136. </div>
  137. </div>
  138. <div class="member">
  139. <h3 class="name" id="thickness" translate="no">.<a href="#thickness">thickness</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  140. <div class="description">
  141. <p>The thickness of the ambient occlusion.</p>
  142. </div>
  143. </div>
  144. <div class="member">
  145. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  146. <div class="description">
  147. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node renders
  148. its effect once per frame in <code>updateBefore()</code>.</p>
  149. <p>Default is <code>'frame'</code>.</p>
  150. </div>
  151. <dl class="details">
  152. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  153. </dl>
  154. </div>
  155. <div class="member">
  156. <h3 class="name" id="useTemporalFiltering" translate="no">.<a href="#useTemporalFiltering">useTemporalFiltering</a><span class="type-signature"> : boolean</span> </h3>
  157. <div class="description">
  158. <p>Whether to use temporal filtering or not. Setting this property to
  159. <code>true</code> requires the usage of <code>TRAANode</code>. This will help to reduce noise
  160. although it introduces typical TAA artifacts like ghosting and temporal
  161. instabilities.</p>
  162. <p>If setting this property to <code>false</code>, a manual denoise via <code>DenoiseNode</code>
  163. might be required.</p>
  164. <p>Default is <code>false</code>.</p>
  165. </div>
  166. </div>
  167. <h2 class="subsection-title">Methods</h2>
  168. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  169. <div class="method">
  170. <div class="description">
  171. <p>Frees internal resources. This method should be called
  172. when the effect is no longer required.</p>
  173. </div>
  174. <dl class="details">
  175. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  176. </dl>
  177. </div>
  178. <h3 class="name name-method" id="getTextureNode" translate="no">.<a href="#getTextureNode">getTextureNode</a><span class="signature">()</span><span class="type-signature"> : <a href="PassTextureNode.html">PassTextureNode</a></span> </h3>
  179. <div class="method">
  180. <div class="description">
  181. <p>Returns the result of the effect as a texture node.</p>
  182. </div>
  183. <dl class="details">
  184. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  185. </dl>
  186. </div>
  187. <h3 class="name name-method" id="setSize" translate="no">.<a href="#setSize">setSize</a><span class="signature">( width : <span class="param-type">number</span>, height : <span class="param-type">number</span> )</span> </h3>
  188. <div class="method">
  189. <div class="description">
  190. <p>Sets the size of the effect.</p>
  191. </div>
  192. <table class="params">
  193. <tbody>
  194. <tr>
  195. <td class="name">
  196. <strong>width</strong>
  197. </td>
  198. <td class="description last">
  199. <p>The width of the effect.</p>
  200. </td>
  201. </tr>
  202. <tr>
  203. <td class="name">
  204. <strong>height</strong>
  205. </td>
  206. <td class="description last">
  207. <p>The height of the effect.</p>
  208. </td>
  209. </tr>
  210. </tbody>
  211. </table>
  212. </div>
  213. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="PassTextureNode.html">PassTextureNode</a></span> </h3>
  214. <div class="method">
  215. <div class="description">
  216. <p>This method is used to setup the effect's TSL code.</p>
  217. </div>
  218. <table class="params">
  219. <tbody>
  220. <tr>
  221. <td class="name">
  222. <strong>builder</strong>
  223. </td>
  224. <td class="description last">
  225. <p>The current node builder.</p>
  226. </td>
  227. </tr>
  228. </tbody>
  229. </table>
  230. <dl class="details">
  231. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  232. </dl>
  233. </div>
  234. <h3 class="name name-method" id="updateBefore" translate="no">.<a href="#updateBefore">updateBefore</a><span class="signature">( frame : <span class="param-type"><a href="NodeFrame.html">NodeFrame</a></span> )</span> </h3>
  235. <div class="method">
  236. <div class="description">
  237. <p>This method is used to render the effect once per frame.</p>
  238. </div>
  239. <table class="params">
  240. <tbody>
  241. <tr>
  242. <td class="name">
  243. <strong>frame</strong>
  244. </td>
  245. <td class="description last">
  246. <p>The current node frame.</p>
  247. </td>
  248. </tr>
  249. </tbody>
  250. </table>
  251. <dl class="details">
  252. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</a></dt>
  253. </dl>
  254. </div>
  255. <h2 class="subsection-title">Source</h2>
  256. <p>
  257. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/display/GTAONode.js" translate="no" target="_blank" rel="noopener">examples/jsm/tsl/display/GTAONode.js</a>
  258. </p>
  259. </article>
  260. </section>
  261. <script src="../scripts/linenumber.js"></script>
  262. <script src="../scripts/page.js"></script>
  263. </body>
  264. </html>
粤ICP备19079148号