SSRPass.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>SSRPass - 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="Pass.html">Pass</a> → </p>
  13. <h1 translate="no">SSRPass</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A pass for a basic SSR effect.</p></div>
  17. <h2>Code Example</h2>
  18. <div translate="no"><pre><code class="language-js">const ssrPass = new SSRPass( {
  19. renderer,
  20. scene,
  21. camera,
  22. width: innerWidth,
  23. height: innerHeight
  24. } );
  25. composer.addPass( ssrPass );
  26. </code></pre></div>
  27. </header>
  28. <article>
  29. <h2 class="subsection-title">Import</h2>
  30. <p><span translate="no">SSRPass</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  31. <pre><code class="language-js">import { SSRPass } from 'three/addons/postprocessing/SSRPass.js';</code></pre>
  32. <div class="container-overview">
  33. <h2>Constructor</h2>
  34. <h3 class="name name-method" id="SSRPass" translate="no">new <a href="#SSRPass">SSRPass</a><span class="signature">( options : <span class="param-type">SSRPass~Options</span> )</span> </h3>
  35. <div class="method">
  36. <div class="description">
  37. <p>Constructs a new SSR pass.</p>
  38. </div>
  39. <table class="params">
  40. <tbody>
  41. <tr>
  42. <td class="name"><code>options</code></td>
  43. <td class="description last"><p>The pass options.</p></td>
  44. </tr>
  45. </tbody>
  46. </table>
  47. </div>
  48. </div>
  49. <h2 class="subsection-title">Properties</h2>
  50. <div class="member">
  51. <h3 class="name" id="blur" translate="no">.<a href="#blur">blur</a><span class="type-signature"> : boolean</span> </h3>
  52. <div class="description">
  53. <p>Whether to blur reflections or not.<br/>Default is <code>true</code>.</p>
  54. </div>
  55. </div>
  56. <div class="member">
  57. <h3 class="name" id="bouncing" translate="no">.<a href="#bouncing">bouncing</a><span class="type-signature"> : boolean</span> </h3>
  58. <div class="description">
  59. <p>Whether bouncing is enabled or not.<br/>Default is <code>false</code>.</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  64. <div class="description">
  65. <p>The camera.</p>
  66. </div>
  67. </div>
  68. <div class="member">
  69. <h3 class="name" id="clear" translate="no">.<a href="#clear">clear</a><span class="type-signature"> : boolean</span> </h3>
  70. <div class="description">
  71. <p>Overwritten to perform a clear operation by default.<br/>Default is <code>true</code>.</p>
  72. </div>
  73. <dl class="details">
  74. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#clear">Pass#clear</a></dt>
  75. </dl>
  76. </div>
  77. <div class="member">
  78. <h3 class="name" id="distanceAttenuation" translate="no">.<a href="#distanceAttenuation">distanceAttenuation</a><span class="type-signature"> : boolean</span> </h3>
  79. <div class="description">
  80. <p>Whether to use distance attenuation or not.<br/>Default is <code>true</code>.</p>
  81. </div>
  82. </div>
  83. <div class="member">
  84. <h3 class="name" id="fresnel" translate="no">.<a href="#fresnel">fresnel</a><span class="type-signature"> : boolean</span> </h3>
  85. <div class="description">
  86. <p>Whether to use fresnel or not.<br/>Default is <code>true</code>.</p>
  87. </div>
  88. </div>
  89. <div class="member">
  90. <h3 class="name" id="groundReflector" translate="no">.<a href="#groundReflector">groundReflector</a><span class="type-signature"> : <a href="ReflectorForSSRPass.html">ReflectorForSSRPass</a></span> </h3>
  91. <div class="description">
  92. <p>The ground reflector.<br/>Default is <code>0</code>.</p>
  93. </div>
  94. </div>
  95. <div class="member">
  96. <h3 class="name" id="height" translate="no">.<a href="#height">height</a><span class="type-signature"> : number</span> </h3>
  97. <div class="description">
  98. <p>The height of the effect.<br/>Default is <code>512</code>.</p>
  99. </div>
  100. </div>
  101. <div class="member">
  102. <h3 class="name" id="infiniteThick" translate="no">.<a href="#infiniteThick">infiniteThick</a><span class="type-signature"> : boolean</span> </h3>
  103. <div class="description">
  104. <p>Whether to use infinite thickness or not.<br/>Default is <code>false</code>.</p>
  105. </div>
  106. </div>
  107. <div class="member">
  108. <h3 class="name" id="maxDistance" translate="no">.<a href="#maxDistance">maxDistance</a><span class="type-signature"> : number</span> </h3>
  109. <div class="description">
  110. <p>Controls how far a fragment can reflect.<br/>Default is <code>180</code>.</p>
  111. </div>
  112. </div>
  113. <div class="member">
  114. <h3 class="name" id="opacity" translate="no">.<a href="#opacity">opacity</a><span class="type-signature"> : number</span> </h3>
  115. <div class="description">
  116. <p>The opacity.<br/>Default is <code>0.5</code>.</p>
  117. </div>
  118. </div>
  119. <div class="member">
  120. <h3 class="name" id="output" translate="no">.<a href="#output">output</a><span class="type-signature"> : number</span> </h3>
  121. <div class="description">
  122. <p>The output configuration.<br/>Default is <code>0</code>.</p>
  123. </div>
  124. </div>
  125. <div class="member">
  126. <h3 class="name" id="renderer" translate="no">.<a href="#renderer">renderer</a><span class="type-signature"> : <a href="WebGLRenderer.html">WebGLRenderer</a></span> </h3>
  127. <div class="description">
  128. <p>The renderer.</p>
  129. </div>
  130. </div>
  131. <div class="member">
  132. <h3 class="name" id="resolutionScale" translate="no">.<a href="#resolutionScale">resolutionScale</a><span class="type-signature"> : number</span> </h3>
  133. <div class="description">
  134. <p>The resolution scale. Valid values are in the range
  135. <code>[0,1]</code>. <code>1</code> means best quality but also results in
  136. more computational overhead. Setting to <code>0.5</code> means
  137. the effect is computed in half-resolution.<br/>Default is <code>1</code>.</p>
  138. </div>
  139. </div>
  140. <div class="member">
  141. <h3 class="name" id="scene" translate="no">.<a href="#scene">scene</a><span class="type-signature"> : <a href="Scene.html">Scene</a></span> </h3>
  142. <div class="description">
  143. <p>The scene to render.</p>
  144. </div>
  145. </div>
  146. <div class="member">
  147. <h3 class="name" id="selective" translate="no">.<a href="#selective">selective</a><span class="type-signature"> : boolean</span> </h3>
  148. <div class="description">
  149. <p>Whether the pass is selective or not.<br/>Default is <code>false</code>.</p>
  150. </div>
  151. </div>
  152. <div class="member">
  153. <h3 class="name" id="selects" translate="no">.<a href="#selects">selects</a><span class="type-signature"> : Array.&lt;<a href="Object3D.html">Object3D</a>></span> </h3>
  154. <div class="description">
  155. <p>Which 3D objects should be affected by SSR. If not set, the entire scene is affected.<br/>Default is <code>null</code>.</p>
  156. </div>
  157. </div>
  158. <div class="member">
  159. <h3 class="name" id="thickness" translate="no">.<a href="#thickness">thickness</a><span class="type-signature"> : number</span> </h3>
  160. <div class="description">
  161. <p>Controls the cutoff between what counts as a
  162. possible reflection hit and what does not.<br/>Default is <code>.018</code>.</p>
  163. </div>
  164. </div>
  165. <div class="member">
  166. <h3 class="name" id="width" translate="no">.<a href="#width">width</a><span class="type-signature"> : number</span> </h3>
  167. <div class="description">
  168. <p>The width of the effect.<br/>Default is <code>512</code>.</p>
  169. </div>
  170. </div>
  171. <h2 class="subsection-title">Methods</h2>
  172. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  173. <div class="method">
  174. <div class="description">
  175. <p>Frees the GPU-related resources allocated by this instance. Call this
  176. method whenever the pass is no longer used in your app.</p>
  177. </div>
  178. <dl class="details">
  179. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#dispose">Pass#dispose</a></dt>
  180. </dl>
  181. </div>
  182. <h3 class="name name-method" id="render" translate="no">.<a href="#render">render</a><span class="signature">( renderer : <span class="param-type">WebGLRenderer</span>, writeBuffer : <span class="param-type">WebGLRenderTarget</span>, readBuffer : <span class="param-type">WebGLRenderTarget</span>, deltaTime : <span class="param-type">number</span>, maskActive : <span class="param-type">boolean</span> )</span> </h3>
  183. <div class="method">
  184. <div class="description">
  185. <p>Performs the SSR pass.</p>
  186. </div>
  187. <table class="params">
  188. <tbody>
  189. <tr>
  190. <td class="name"><code>renderer</code></td>
  191. <td class="description last"><p>The renderer.</p></td>
  192. </tr>
  193. <tr>
  194. <td class="name"><code>writeBuffer</code></td>
  195. <td class="description last"><p>The write buffer. This buffer is intended as the rendering
  196. destination for the pass.</p></td>
  197. </tr>
  198. <tr>
  199. <td class="name"><code>readBuffer</code></td>
  200. <td class="description last"><p>The read buffer. The pass can access the result from the
  201. previous pass from this buffer.</p></td>
  202. </tr>
  203. <tr>
  204. <td class="name"><code>deltaTime</code></td>
  205. <td class="description last"><p>The delta time in seconds.</p></td>
  206. </tr>
  207. <tr>
  208. <td class="name"><code>maskActive</code></td>
  209. <td class="description last"><p>Whether masking is active or not.</p></td>
  210. </tr>
  211. </tbody>
  212. </table>
  213. <dl class="details">
  214. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#render">Pass#render</a></dt>
  215. </dl>
  216. </div>
  217. <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>
  218. <div class="method">
  219. <div class="description">
  220. <p>Sets the size of the pass.</p>
  221. </div>
  222. <table class="params">
  223. <tbody>
  224. <tr>
  225. <td class="name"><code>width</code></td>
  226. <td class="description last"><p>The width to set.</p></td>
  227. </tr>
  228. <tr>
  229. <td class="name"><code>height</code></td>
  230. <td class="description last"><p>The height to set.</p></td>
  231. </tr>
  232. </tbody>
  233. </table>
  234. <dl class="details">
  235. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#setSize">Pass#setSize</a></dt>
  236. </dl>
  237. </div>
  238. <h2 class="subsection-title">Type Definitions</h2>
  239. <div class="member">
  240. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  241. <div class="description">
  242. <p>Constructor options of <code>SSRPass</code>.</p>
  243. </div>
  244. <h5 class="subsection-title">Properties:</h5>
  245. <table class="props">
  246. <thead>
  247. <tr>
  248. <th>Name</th>
  249. <th>Type</th>
  250. <th>Attributes</th>
  251. <th>Default</th>
  252. <th class="last">Description</th>
  253. </tr>
  254. </thead>
  255. <tbody>
  256. <tr>
  257. <td class="name"><code>renderer</code></td>
  258. <td class="type">
  259. <span class="param-type"><a href="WebGLRenderer.html">WebGLRenderer</a></span>
  260. </td>
  261. <td class="attributes">
  262. </td>
  263. <td class="default">
  264. </td>
  265. <td class="description last"><p>The renderer.</p></td>
  266. </tr>
  267. <tr>
  268. <td class="name"><code>scene</code></td>
  269. <td class="type">
  270. <span class="param-type"><a href="Scene.html">Scene</a></span>
  271. </td>
  272. <td class="attributes">
  273. </td>
  274. <td class="default">
  275. </td>
  276. <td class="description last"><p>The scene to render.</p></td>
  277. </tr>
  278. <tr>
  279. <td class="name"><code>camera</code></td>
  280. <td class="type">
  281. <span class="param-type"><a href="Camera.html">Camera</a></span>
  282. </td>
  283. <td class="attributes">
  284. </td>
  285. <td class="default">
  286. </td>
  287. <td class="description last"><p>The camera.</p></td>
  288. </tr>
  289. <tr>
  290. <td class="name"><code>width</code></td>
  291. <td class="type">
  292. <span class="param-type">number</span>
  293. </td>
  294. <td class="attributes">
  295. &lt;optional><br>
  296. </td>
  297. <td class="default">
  298. 512
  299. </td>
  300. <td class="description last"><p>The width of the effect.</p></td>
  301. </tr>
  302. <tr>
  303. <td class="name"><code>height</code></td>
  304. <td class="type">
  305. <span class="param-type">number</span>
  306. </td>
  307. <td class="attributes">
  308. &lt;optional><br>
  309. </td>
  310. <td class="default">
  311. 512
  312. </td>
  313. <td class="description last"><p>The width of the effect.</p></td>
  314. </tr>
  315. <tr>
  316. <td class="name"><code>selects</code></td>
  317. <td class="type">
  318. <span class="param-type">Array.&lt;<a href="Object3D.html">Object3D</a>></span>
  319. </td>
  320. <td class="attributes">
  321. &lt;optional><br>
  322. &lt;nullable><br>
  323. </td>
  324. <td class="default">
  325. null
  326. </td>
  327. <td class="description last"><p>Which 3D objects should be affected by SSR. If not set, the entire scene is affected.</p></td>
  328. </tr>
  329. <tr>
  330. <td class="name"><code>bouncing</code></td>
  331. <td class="type">
  332. <span class="param-type">boolean</span>
  333. </td>
  334. <td class="attributes">
  335. &lt;optional><br>
  336. </td>
  337. <td class="default">
  338. false
  339. </td>
  340. <td class="description last"><p>Whether bouncing is enabled or not.</p></td>
  341. </tr>
  342. <tr>
  343. <td class="name"><code>groundReflector</code></td>
  344. <td class="type">
  345. <span class="param-type"><a href="ReflectorForSSRPass.html">ReflectorForSSRPass</a></span>
  346. </td>
  347. <td class="attributes">
  348. &lt;optional><br>
  349. &lt;nullable><br>
  350. </td>
  351. <td class="default">
  352. null
  353. </td>
  354. <td class="description last"><p>A ground reflector.</p></td>
  355. </tr>
  356. </tbody>
  357. </table>
  358. </div>
  359. <h2 class="subsection-title">Source</h2>
  360. <p>
  361. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/postprocessing/SSRPass.js" target="_blank" rel="noopener" translate="no">examples/jsm/postprocessing/SSRPass.js</a>
  362. </p>
  363. </article>
  364. </section>
  365. <script src="../scripts/linenumber.js"></script>
  366. <script src="../scripts/page.js"></script>
  367. </body>
  368. </html>
粤ICP备19079148号