1
0

TRAANode.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>TRAANode - 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">TRAANode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A special node that applies TRAA (Temporal Reprojection Anti-Aliasing).</p>
  17. <p>References:</p>
  18. <ul>
  19. <li><a href="https://alextardif.com/TAA.html" target="_blank" rel="noopener">https://alextardif.com/TAA.html</a></li>
  20. <li><a href="https://www.elopezr.com/temporal-aa-and-the-quest-for-the-holy-trail/" target="_blank" rel="noopener">https://www.elopezr.com/temporal-aa-and-the-quest-for-the-holy-trail/</a></li>
  21. </ul>
  22. <p>Note: MSAA must be disabled when TRAA is in use.</p></div>
  23. </header>
  24. <article>
  25. <h2 class="subsection-title">Import</h2>
  26. <p><span translate="no">TRAANode</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>
  27. <pre><code class="language-js">import { traa } from 'three/addons/tsl/display/TRAANode.js';</code></pre>
  28. <div class="container-overview">
  29. <h2>Constructor</h2>
  30. <h3 class="name name-method" id="TRAANode" translate="no">new <a href="#TRAANode">TRAANode</a><span class="signature">( beautyNode : <span class="param-type"><a href="TextureNode.html">TextureNode</a></span>, depthNode : <span class="param-type"><a href="TextureNode.html">TextureNode</a></span>, velocityNode : <span class="param-type"><a href="TextureNode.html">TextureNode</a></span>, camera : <span class="param-type"><a href="Camera.html">Camera</a></span> )</span> </h3>
  31. <div class="method">
  32. <div class="description">
  33. <p>Constructs a new TRAA node.</p>
  34. </div>
  35. <table class="params">
  36. <tbody>
  37. <tr>
  38. <td class="name">
  39. <strong translate="no">beautyNode</strong>
  40. </td>
  41. <td class="description last">
  42. <p>The texture node that represents the input of the effect.</p>
  43. </td>
  44. </tr>
  45. <tr>
  46. <td class="name">
  47. <strong translate="no">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 translate="no">velocityNode</strong>
  56. </td>
  57. <td class="description last">
  58. <p>A node that represents the scene's velocity.</p>
  59. </td>
  60. </tr>
  61. <tr>
  62. <td class="name">
  63. <strong translate="no">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="beautyNode" translate="no">.<a href="#beautyNode">beautyNode</a><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  76. <div class="description">
  77. <p>The texture node that represents the input of the effect.</p>
  78. </div>
  79. </div>
  80. <div class="member">
  81. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  82. <div class="description">
  83. <p>The camera the scene is rendered with.</p>
  84. </div>
  85. </div>
  86. <div class="member">
  87. <h3 class="name" id="depthNode" translate="no">.<a href="#depthNode">depthNode</a><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  88. <div class="description">
  89. <p>A node that represents the scene's velocity.</p>
  90. </div>
  91. </div>
  92. <div class="member">
  93. <h3 class="name" id="depthThreshold" translate="no">.<a href="#depthThreshold">depthThreshold</a><span class="type-signature"> : number</span> </h3>
  94. <div class="description">
  95. <p>When the difference between the current and previous depth goes above this threshold,
  96. the history is considered invalid.</p>
  97. <p>Default is <code>0.0005</code>.</p>
  98. </div>
  99. </div>
  100. <div class="member">
  101. <h3 class="name" id="edgeDepthDiff" translate="no">.<a href="#edgeDepthDiff">edgeDepthDiff</a><span class="type-signature"> : number</span> </h3>
  102. <div class="description">
  103. <p>The depth difference within the 3×3 neighborhood to consider a pixel as an edge.</p>
  104. <p>Default is <code>0.001</code>.</p>
  105. </div>
  106. </div>
  107. <div class="member">
  108. <h3 class="name" id="isTRAANode" translate="no">.<a href="#isTRAANode">isTRAANode</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  109. <div class="description">
  110. <p>This flag can be used for type testing.</p>
  111. <p>Default is <code>true</code>.</p>
  112. </div>
  113. </div>
  114. <div class="member">
  115. <h3 class="name" id="maxVelocityLength" translate="no">.<a href="#maxVelocityLength">maxVelocityLength</a><span class="type-signature"> : number</span> </h3>
  116. <div class="description">
  117. <p>The history becomes invalid as the pixel length of the velocity approaches this value.</p>
  118. <p>Default is <code>128</code>.</p>
  119. </div>
  120. </div>
  121. <div class="member">
  122. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  123. <div class="description">
  124. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node renders
  125. its effect once per frame in <code>updateBefore()</code>.</p>
  126. <p>Default is <code>'frame'</code>.</p>
  127. </div>
  128. <dl class="details">
  129. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  130. </dl>
  131. </div>
  132. <div class="member">
  133. <h3 class="name" id="useSubpixelCorrection" translate="no">.<a href="#useSubpixelCorrection">useSubpixelCorrection</a><span class="type-signature"> : boolean</span> </h3>
  134. <div class="description">
  135. <p>Whether to decrease the weight on the current frame when the velocity is more subpixel.
  136. This reduces blurriness under motion, but can introduce a square pattern artifact.</p>
  137. <p>Default is <code>true</code>.</p>
  138. </div>
  139. </div>
  140. <div class="member">
  141. <h3 class="name" id="velocityNode" translate="no">.<a href="#velocityNode">velocityNode</a><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  142. <div class="description">
  143. <p>A node that represents the scene's velocity.</p>
  144. </div>
  145. </div>
  146. <h2 class="subsection-title">Methods</h2>
  147. <h3 class="name name-method" id="clearViewOffset" translate="no">.<a href="#clearViewOffset">clearViewOffset</a><span class="signature">()</span> </h3>
  148. <div class="method">
  149. <div class="description">
  150. <p>Clears the view offset from the scene's camera.</p>
  151. </div>
  152. </div>
  153. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  154. <div class="method">
  155. <div class="description">
  156. <p>Frees internal resources. This method should be called
  157. when the effect is no longer required.</p>
  158. </div>
  159. <dl class="details">
  160. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  161. </dl>
  162. </div>
  163. <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>
  164. <div class="method">
  165. <div class="description">
  166. <p>Returns the result of the effect as a texture node.</p>
  167. </div>
  168. <dl class="details">
  169. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  170. </dl>
  171. </div>
  172. <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>
  173. <div class="method">
  174. <div class="description">
  175. <p>Sets the size of the effect.</p>
  176. </div>
  177. <table class="params">
  178. <tbody>
  179. <tr>
  180. <td class="name">
  181. <strong translate="no">width</strong>
  182. </td>
  183. <td class="description last">
  184. <p>The width of the effect.</p>
  185. </td>
  186. </tr>
  187. <tr>
  188. <td class="name">
  189. <strong translate="no">height</strong>
  190. </td>
  191. <td class="description last">
  192. <p>The height of the effect.</p>
  193. </td>
  194. </tr>
  195. </tbody>
  196. </table>
  197. </div>
  198. <h3 class="name name-method" id="setViewOffset" translate="no">.<a href="#setViewOffset">setViewOffset</a><span class="signature">( width : <span class="param-type">number</span>, height : <span class="param-type">number</span> )</span> </h3>
  199. <div class="method">
  200. <div class="description">
  201. <p>Defines the TRAA's current jitter as a view offset
  202. to the scene's camera.</p>
  203. </div>
  204. <table class="params">
  205. <tbody>
  206. <tr>
  207. <td class="name">
  208. <strong translate="no">width</strong>
  209. </td>
  210. <td class="description last">
  211. <p>The width of the effect.</p>
  212. </td>
  213. </tr>
  214. <tr>
  215. <td class="name">
  216. <strong translate="no">height</strong>
  217. </td>
  218. <td class="description last">
  219. <p>The height of the effect.</p>
  220. </td>
  221. </tr>
  222. </tbody>
  223. </table>
  224. </div>
  225. <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>
  226. <div class="method">
  227. <div class="description">
  228. <p>This method is used to setup the effect's render targets and TSL code.</p>
  229. </div>
  230. <table class="params">
  231. <tbody>
  232. <tr>
  233. <td class="name">
  234. <strong translate="no">builder</strong>
  235. </td>
  236. <td class="description last">
  237. <p>The current node builder.</p>
  238. </td>
  239. </tr>
  240. </tbody>
  241. </table>
  242. <dl class="details">
  243. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  244. </dl>
  245. </div>
  246. <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>
  247. <div class="method">
  248. <div class="description">
  249. <p>This method is used to render the effect once per frame.</p>
  250. </div>
  251. <table class="params">
  252. <tbody>
  253. <tr>
  254. <td class="name">
  255. <strong translate="no">frame</strong>
  256. </td>
  257. <td class="description last">
  258. <p>The current node frame.</p>
  259. </td>
  260. </tr>
  261. </tbody>
  262. </table>
  263. <dl class="details">
  264. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</a></dt>
  265. </dl>
  266. </div>
  267. <h2 class="subsection-title">Source</h2>
  268. <p>
  269. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/display/TRAANode.js" translate="no" target="_blank" rel="noopener">examples/jsm/tsl/display/TRAANode.js</a>
  270. </p>
  271. </article>
  272. </section>
  273. <script src="../scripts/linenumber.js"></script>
  274. <script src="../scripts/page.js"></script>
  275. </body>
  276. </html>
粤ICP备19079148号