SSRNode.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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" target="_blank" rel="noopener">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" rel="noopener">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"><a href="Node.html">Node</a>.&lt;vec4></span>, 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>, metalnessNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;float></span>, roughnessNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;float></span>, camera : <span class="param-type"><a href="Camera.html">Camera</a></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">
  34. <strong>colorNode</strong>
  35. </td>
  36. <td class="description last">
  37. <p>The node that represents the beauty pass.</p>
  38. </td>
  39. </tr>
  40. <tr>
  41. <td class="name">
  42. <strong>depthNode</strong>
  43. </td>
  44. <td class="description last">
  45. <p>A node that represents the beauty pass's depth.</p>
  46. </td>
  47. </tr>
  48. <tr>
  49. <td class="name">
  50. <strong>normalNode</strong>
  51. </td>
  52. <td class="description last">
  53. <p>A node that represents the beauty pass's normals.</p>
  54. </td>
  55. </tr>
  56. <tr>
  57. <td class="name">
  58. <strong>metalnessNode</strong>
  59. </td>
  60. <td class="description last">
  61. <p>A node that represents the beauty pass's metalness.</p>
  62. </td>
  63. </tr>
  64. <tr>
  65. <td class="name">
  66. <strong>roughnessNode</strong>
  67. </td>
  68. <td class="description last">
  69. <p>A node that represents the beauty pass's roughness.</p>
  70. <p>Default is <code>null</code>.</p>
  71. </td>
  72. </tr>
  73. <tr>
  74. <td class="name">
  75. <strong>camera</strong>
  76. </td>
  77. <td class="description last">
  78. <p>The camera the scene is rendered with.</p>
  79. <p>Default is <code>null</code>.</p>
  80. </td>
  81. </tr>
  82. </tbody>
  83. </table>
  84. </div>
  85. </div>
  86. <h2 class="subsection-title">Properties</h2>
  87. <div class="member">
  88. <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>
  89. <div class="description">
  90. <p>The quality of the blur. Must be an integer in the range <code>[1,3]</code>.</p>
  91. </div>
  92. </div>
  93. <div class="member">
  94. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  95. <div class="description">
  96. <p>The camera the scene is rendered with.</p>
  97. </div>
  98. </div>
  99. <div class="member">
  100. <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>
  101. <div class="description">
  102. <p>The node that represents the beauty pass.</p>
  103. </div>
  104. </div>
  105. <div class="member">
  106. <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>
  107. <div class="description">
  108. <p>A node that represents the beauty pass's depth.</p>
  109. </div>
  110. </div>
  111. <div class="member">
  112. <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>
  113. <div class="description">
  114. <p>Controls how far a fragment can reflect. Increasing this value result in more
  115. computational overhead but also increases the reflection distance.</p>
  116. </div>
  117. </div>
  118. <div class="member">
  119. <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>
  120. <div class="description">
  121. <p>A node that represents the beauty pass's metalness.</p>
  122. </div>
  123. </div>
  124. <div class="member">
  125. <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>
  126. <div class="description">
  127. <p>A node that represents the beauty pass's normals.</p>
  128. </div>
  129. </div>
  130. <div class="member">
  131. <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>
  132. <div class="description">
  133. <p>Controls how the SSR reflections are blended with the beauty pass.</p>
  134. </div>
  135. </div>
  136. <div class="member">
  137. <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>
  138. <div class="description">
  139. <p>This parameter controls how detailed the raymarching process works.
  140. The value ranges is <code>[0,1]</code> where <code>1</code> means best quality (the maximum number
  141. of raymarching iterations/samples) and <code>0</code> means no samples at all.</p>
  142. <p>A quality of <code>0.5</code> is usually sufficient for most use cases. Try to keep
  143. this parameter as low as possible. Larger values result in noticeable more
  144. overhead.</p>
  145. </div>
  146. </div>
  147. <div class="member">
  148. <h3 class="name" id="resolutionScale" translate="no">.<a href="#resolutionScale">resolutionScale</a><span class="type-signature"> : number</span> </h3>
  149. <div class="description">
  150. <p>The resolution scale. Valid values are in the range
  151. <code>[0,1]</code>. <code>1</code> means best quality but also results in
  152. more computational overhead. Setting to <code>0.5</code> means
  153. the effect is computed in half-resolution.</p>
  154. <p>Default is <code>1</code>.</p>
  155. </div>
  156. </div>
  157. <div class="member">
  158. <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>
  159. <div class="description">
  160. <p>Controls the cutoff between what counts as a possible reflection hit and what does not.</p>
  161. </div>
  162. </div>
  163. <div class="member">
  164. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  165. <div class="description">
  166. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node renders
  167. its effect once per frame in <code>updateBefore()</code>.</p>
  168. <p>Default is <code>'frame'</code>.</p>
  169. </div>
  170. <dl class="details">
  171. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  172. </dl>
  173. </div>
  174. <h2 class="subsection-title">Methods</h2>
  175. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  176. <div class="method">
  177. <div class="description">
  178. <p>Frees internal resources. This method should be called
  179. when the effect is no longer required.</p>
  180. </div>
  181. <dl class="details">
  182. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  183. </dl>
  184. </div>
  185. <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>
  186. <div class="method">
  187. <div class="description">
  188. <p>Returns the result of the effect as a texture node.</p>
  189. </div>
  190. <dl class="details">
  191. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  192. </dl>
  193. </div>
  194. <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>
  195. <div class="method">
  196. <div class="description">
  197. <p>Sets the size of the effect.</p>
  198. </div>
  199. <table class="params">
  200. <tbody>
  201. <tr>
  202. <td class="name">
  203. <strong>width</strong>
  204. </td>
  205. <td class="description last">
  206. <p>The width of the effect.</p>
  207. </td>
  208. </tr>
  209. <tr>
  210. <td class="name">
  211. <strong>height</strong>
  212. </td>
  213. <td class="description last">
  214. <p>The height of the effect.</p>
  215. </td>
  216. </tr>
  217. </tbody>
  218. </table>
  219. </div>
  220. <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>
  221. <div class="method">
  222. <div class="description">
  223. <p>This method is used to setup the effect's TSL code.</p>
  224. </div>
  225. <table class="params">
  226. <tbody>
  227. <tr>
  228. <td class="name">
  229. <strong>builder</strong>
  230. </td>
  231. <td class="description last">
  232. <p>The current node builder.</p>
  233. </td>
  234. </tr>
  235. </tbody>
  236. </table>
  237. <dl class="details">
  238. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  239. </dl>
  240. </div>
  241. <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>
  242. <div class="method">
  243. <div class="description">
  244. <p>This method is used to render the effect once per frame.</p>
  245. </div>
  246. <table class="params">
  247. <tbody>
  248. <tr>
  249. <td class="name">
  250. <strong>frame</strong>
  251. </td>
  252. <td class="description last">
  253. <p>The current node frame.</p>
  254. </td>
  255. </tr>
  256. </tbody>
  257. </table>
  258. <dl class="details">
  259. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</a></dt>
  260. </dl>
  261. </div>
  262. <h2 class="subsection-title">Source</h2>
  263. <p>
  264. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/display/SSRNode.js" translate="no" target="_blank" rel="noopener">examples/jsm/tsl/display/SSRNode.js</a>
  265. </p>
  266. </article>
  267. </section>
  268. <script src="../scripts/linenumber.js"></script>
  269. <script src="../scripts/page.js"></script>
  270. </body>
  271. </html>
粤ICP备19079148号