SSRNode.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>SSRNode - 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">SSRNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Post processing node for computing screen space reflections (SSR).</p>
  17. <p>Reference: <a href="https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-reflection.html">https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-reflection.html</a></p></div>
  18. </header>
  19. <article>
  20. <h2 class="subsection-title">Import</h2>
  21. <p><span translate="no">SSRNode</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  22. <pre><code class="language-js">import { ssr } from 'three/addons/tsl/display/SSRNode.js';</code></pre>
  23. <div class="container-overview">
  24. <h2>Constructor</h2>
  25. <h3 class="name name-method" id="SSRNode" translate="no">new <a href="#SSRNode">SSRNode</a><span class="signature">( colorNode : <span class="param-type">Node.&lt;vec4></span>, depthNode : <span class="param-type">Node.&lt;float></span>, normalNode : <span class="param-type">Node.&lt;vec3></span>, metalnessNode : <span class="param-type">Node.&lt;float></span>, roughnessNode : <span class="param-type">Node.&lt;float></span>, camera : <span class="param-type">Camera</span> )</span> </h3>
  26. <div class="method">
  27. <div class="description">
  28. <p>Constructs a new SSR node.</p>
  29. </div>
  30. <table class="params">
  31. <tbody>
  32. <tr>
  33. <td class="name"><code>colorNode</code></td>
  34. <td class="description last"><p>The node that represents the beauty pass.</p></td>
  35. </tr>
  36. <tr>
  37. <td class="name"><code>depthNode</code></td>
  38. <td class="description last"><p>A node that represents the beauty pass's depth.</p></td>
  39. </tr>
  40. <tr>
  41. <td class="name"><code>normalNode</code></td>
  42. <td class="description last"><p>A node that represents the beauty pass's normals.</p></td>
  43. </tr>
  44. <tr>
  45. <td class="name"><code>metalnessNode</code></td>
  46. <td class="description last"><p>A node that represents the beauty pass's metalness.</p></td>
  47. </tr>
  48. <tr>
  49. <td class="name"><code>roughnessNode</code></td>
  50. <td class="description last"><p>A node that represents the beauty pass's roughness.<br/>Default is <code>null</code>.</p></td>
  51. </tr>
  52. <tr>
  53. <td class="name"><code>camera</code></td>
  54. <td class="description last"><p>The camera the scene is rendered with.<br/>Default is <code>null</code>.</p></td>
  55. </tr>
  56. </tbody>
  57. </table>
  58. </div>
  59. </div>
  60. <h2 class="subsection-title">Properties</h2>
  61. <div class="member">
  62. <h3 class="name" id="blurQuality" translate="no">.<a href="#blurQuality">blurQuality</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;int></span> </h3>
  63. <div class="description">
  64. <p>The quality of the blur. Must be an integer in the range <code>[1,3]</code>.</p>
  65. </div>
  66. </div>
  67. <div class="member">
  68. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  69. <div class="description">
  70. <p>The camera the scene is rendered with.</p>
  71. </div>
  72. </div>
  73. <div class="member">
  74. <h3 class="name" id="colorNode" translate="no">.<a href="#colorNode">colorNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  75. <div class="description">
  76. <p>The node that represents the beauty pass.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <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>
  81. <div class="description">
  82. <p>A node that represents the beauty pass's depth.</p>
  83. </div>
  84. </div>
  85. <div class="member">
  86. <h3 class="name" id="maxDistance" translate="no">.<a href="#maxDistance">maxDistance</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  87. <div class="description">
  88. <p>Controls how far a fragment can reflect. Increasing this value result in more
  89. computational overhead but also increases the reflection distance.</p>
  90. </div>
  91. </div>
  92. <div class="member">
  93. <h3 class="name" id="metalnessNode" translate="no">.<a href="#metalnessNode">metalnessNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  94. <div class="description">
  95. <p>A node that represents the beauty pass's metalness.</p>
  96. </div>
  97. </div>
  98. <div class="member">
  99. <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>
  100. <div class="description">
  101. <p>A node that represents the beauty pass's normals.</p>
  102. </div>
  103. </div>
  104. <div class="member">
  105. <h3 class="name" id="opacity" translate="no">.<a href="#opacity">opacity</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  106. <div class="description">
  107. <p>Controls how the SSR reflections are blended with the beauty pass.</p>
  108. </div>
  109. </div>
  110. <div class="member">
  111. <h3 class="name" id="quality" translate="no">.<a href="#quality">quality</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  112. <div class="description">
  113. <p>This parameter controls how detailed the raymarching process works.
  114. The value ranges is <code>[0,1]</code> where <code>1</code> means best quality (the maximum number
  115. of raymarching iterations/samples) and <code>0</code> means no samples at all.</p>
  116. <p>A quality of <code>0.5</code> is usually sufficient for most use cases. Try to keep
  117. this parameter as low as possible. Larger values result in noticeable more
  118. overhead.</p>
  119. </div>
  120. </div>
  121. <div class="member">
  122. <h3 class="name" id="resolutionScale" translate="no">.<a href="#resolutionScale">resolutionScale</a><span class="type-signature"> : number</span> </h3>
  123. <div class="description">
  124. <p>The resolution scale. Valid values are in the range
  125. <code>[0,1]</code>. <code>1</code> means best quality but also results in
  126. more computational overhead. Setting to <code>0.5</code> means
  127. the effect is computed in half-resolution.<br/>Default is <code>1</code>.</p>
  128. </div>
  129. </div>
  130. <div class="member">
  131. <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>
  132. <div class="description">
  133. <p>Controls the cutoff between what counts as a possible reflection hit and what does not.</p>
  134. </div>
  135. </div>
  136. <div class="member">
  137. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  138. <div class="description">
  139. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node renders
  140. its effect once per frame in <code>updateBefore()</code>.<br/>Default is <code>'frame'</code>.</p>
  141. </div>
  142. <dl class="details">
  143. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  144. </dl>
  145. </div>
  146. <h2 class="subsection-title">Methods</h2>
  147. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  148. <div class="method">
  149. <div class="description">
  150. <p>Frees internal resources. This method should be called
  151. when the effect is no longer required.</p>
  152. </div>
  153. <dl class="details">
  154. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  155. </dl>
  156. </div>
  157. <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>
  158. <div class="method">
  159. <div class="description">
  160. <p>Returns the result of the effect as a texture node.</p>
  161. </div>
  162. <dl class="details">
  163. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  164. </dl>
  165. </div>
  166. <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>
  167. <div class="method">
  168. <div class="description">
  169. <p>Sets the size of the effect.</p>
  170. </div>
  171. <table class="params">
  172. <tbody>
  173. <tr>
  174. <td class="name"><code>width</code></td>
  175. <td class="description last"><p>The width of the effect.</p></td>
  176. </tr>
  177. <tr>
  178. <td class="name"><code>height</code></td>
  179. <td class="description last"><p>The height of the effect.</p></td>
  180. </tr>
  181. </tbody>
  182. </table>
  183. </div>
  184. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : <a href="PassTextureNode.html">PassTextureNode</a></span> </h3>
  185. <div class="method">
  186. <div class="description">
  187. <p>This method is used to setup the effect's TSL code.</p>
  188. </div>
  189. <table class="params">
  190. <tbody>
  191. <tr>
  192. <td class="name"><code>builder</code></td>
  193. <td class="description last"><p>The current node builder.</p></td>
  194. </tr>
  195. </tbody>
  196. </table>
  197. <dl class="details">
  198. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  199. </dl>
  200. <dl class="details">
  201. <dt class="tag-returns"><strong>Returns:</strong> </dt>
  202. </dl>
  203. </div>
  204. <h3 class="name name-method" id="updateBefore" translate="no">.<a href="#updateBefore">updateBefore</a><span class="signature">( frame : <span class="param-type">NodeFrame</span> )</span> </h3>
  205. <div class="method">
  206. <div class="description">
  207. <p>This method is used to render the effect once per frame.</p>
  208. </div>
  209. <table class="params">
  210. <tbody>
  211. <tr>
  212. <td class="name"><code>frame</code></td>
  213. <td class="description last"><p>The current node frame.</p></td>
  214. </tr>
  215. </tbody>
  216. </table>
  217. <dl class="details">
  218. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</a></dt>
  219. </dl>
  220. </div>
  221. <h2 class="subsection-title">Source</h2>
  222. <p>
  223. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/display/SSRNode.js" target="_blank" rel="noopener" translate="no">examples/jsm/tsl/display/SSRNode.js</a>
  224. </p>
  225. </article>
  226. </section>
  227. <script src="../scripts/linenumber.js"></script>
  228. <script src="../scripts/page.js"></script>
  229. </body>
  230. </html>
粤ICP备19079148号