TRAANode.html 12 KB

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