SSAOPass.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>SSAOPass - 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">SSAOPass</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A pass for a basic SSAO effect.</p>
  17. <p><a href="SAOPass.html">SAOPass</a> and GTAPass produce a more advanced AO but are also
  18. more expensive.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">const ssaoPass = new SSAOPass( scene, camera, width, height );
  21. composer.addPass( ssaoPass );
  22. </code></pre></div>
  23. </header>
  24. <article>
  25. <h2 class="subsection-title">Import</h2>
  26. <p><span translate="no">SSAOPass</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 { SSAOPass } from 'three/addons/postprocessing/SSAOPass.js';</code></pre>
  28. <div class="container-overview">
  29. <h2>Constructor</h2>
  30. <h3 class="name name-method" id="SSAOPass" translate="no">new <a href="#SSAOPass">SSAOPass</a><span class="signature">( scene : <span class="param-type"><a href="Scene.html">Scene</a></span>, camera : <span class="param-type"><a href="Camera.html">Camera</a></span>, width : <span class="param-type">number</span>, height : <span class="param-type">number</span>, kernelSize : <span class="param-type">number</span> )</span> </h3>
  31. <div class="method">
  32. <div class="description">
  33. <p>Constructs a new SSAO pass.</p>
  34. </div>
  35. <table class="params">
  36. <tbody>
  37. <tr>
  38. <td class="name">
  39. <strong>scene</strong>
  40. </td>
  41. <td class="description last">
  42. <p>The scene to compute the AO for.</p>
  43. </td>
  44. </tr>
  45. <tr>
  46. <td class="name">
  47. <strong>camera</strong>
  48. </td>
  49. <td class="description last">
  50. <p>The camera.</p>
  51. </td>
  52. </tr>
  53. <tr>
  54. <td class="name">
  55. <strong>width</strong>
  56. </td>
  57. <td class="description last">
  58. <p>The width of the effect.</p>
  59. <p>Default is <code>512</code>.</p>
  60. </td>
  61. </tr>
  62. <tr>
  63. <td class="name">
  64. <strong>height</strong>
  65. </td>
  66. <td class="description last">
  67. <p>The height of the effect.</p>
  68. <p>Default is <code>512</code>.</p>
  69. </td>
  70. </tr>
  71. <tr>
  72. <td class="name">
  73. <strong>kernelSize</strong>
  74. </td>
  75. <td class="description last">
  76. <p>The kernel size.</p>
  77. <p>Default is <code>32</code>.</p>
  78. </td>
  79. </tr>
  80. </tbody>
  81. </table>
  82. </div>
  83. </div>
  84. <h2 class="subsection-title">Properties</h2>
  85. <div class="member">
  86. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  87. <div class="description">
  88. <p>The camera.</p>
  89. </div>
  90. </div>
  91. <div class="member">
  92. <h3 class="name" id="clear" translate="no">.<a href="#clear">clear</a><span class="type-signature"> : boolean</span> </h3>
  93. <div class="description">
  94. <p>Overwritten to perform a clear operation by default.</p>
  95. <p>Default is <code>true</code>.</p>
  96. </div>
  97. <dl class="details">
  98. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#clear">Pass#clear</a></dt>
  99. </dl>
  100. </div>
  101. <div class="member">
  102. <h3 class="name" id="height" translate="no">.<a href="#height">height</a><span class="type-signature"> : number</span> </h3>
  103. <div class="description">
  104. <p>The height of the effect.</p>
  105. <p>Default is <code>512</code>.</p>
  106. </div>
  107. </div>
  108. <div class="member">
  109. <h3 class="name" id="kernelRadius" translate="no">.<a href="#kernelRadius">kernelRadius</a><span class="type-signature"> : number</span> </h3>
  110. <div class="description">
  111. <p>The kernel radius controls how wide the
  112. AO spreads.</p>
  113. <p>Default is <code>8</code>.</p>
  114. </div>
  115. </div>
  116. <div class="member">
  117. <h3 class="name" id="maxDistance" translate="no">.<a href="#maxDistance">maxDistance</a><span class="type-signature"> : number</span> </h3>
  118. <div class="description">
  119. <p>Defines the maximum distance that should be
  120. affected by the AO.</p>
  121. <p>Default is <code>0.1</code>.</p>
  122. </div>
  123. </div>
  124. <div class="member">
  125. <h3 class="name" id="minDistance" translate="no">.<a href="#minDistance">minDistance</a><span class="type-signature"> : number</span> </h3>
  126. <div class="description">
  127. <p>Defines the minimum distance that should be
  128. affected by the AO.</p>
  129. <p>Default is <code>0.005</code>.</p>
  130. </div>
  131. </div>
  132. <div class="member">
  133. <h3 class="name" id="needsSwap" translate="no">.<a href="#needsSwap">needsSwap</a><span class="type-signature"> : boolean</span> </h3>
  134. <div class="description">
  135. <p>Overwritten to disable the swap.</p>
  136. <p>Default is <code>false</code>.</p>
  137. </div>
  138. <dl class="details">
  139. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#needsSwap">Pass#needsSwap</a></dt>
  140. </dl>
  141. </div>
  142. <div class="member">
  143. <h3 class="name" id="output" translate="no">.<a href="#output">output</a><span class="type-signature"> : number</span> </h3>
  144. <div class="description">
  145. <p>The output configuration.</p>
  146. <p>Default is <code>0</code>.</p>
  147. </div>
  148. </div>
  149. <div class="member">
  150. <h3 class="name" id="scene" translate="no">.<a href="#scene">scene</a><span class="type-signature"> : <a href="Scene.html">Scene</a></span> </h3>
  151. <div class="description">
  152. <p>The scene to render the AO for.</p>
  153. </div>
  154. </div>
  155. <div class="member">
  156. <h3 class="name" id="width" translate="no">.<a href="#width">width</a><span class="type-signature"> : number</span> </h3>
  157. <div class="description">
  158. <p>The width of the effect.</p>
  159. <p>Default is <code>512</code>.</p>
  160. </div>
  161. </div>
  162. <h2 class="subsection-title">Methods</h2>
  163. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  164. <div class="method">
  165. <div class="description">
  166. <p>Frees the GPU-related resources allocated by this instance. Call this
  167. method whenever the pass is no longer used in your app.</p>
  168. </div>
  169. <dl class="details">
  170. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#dispose">Pass#dispose</a></dt>
  171. </dl>
  172. </div>
  173. <h3 class="name name-method" id="render" translate="no">.<a href="#render">render</a><span class="signature">( renderer : <span class="param-type"><a href="WebGLRenderer.html">WebGLRenderer</a></span>, writeBuffer : <span class="param-type"><a href="WebGLRenderTarget.html">WebGLRenderTarget</a></span>, readBuffer : <span class="param-type"><a href="WebGLRenderTarget.html">WebGLRenderTarget</a></span>, deltaTime : <span class="param-type">number</span>, maskActive : <span class="param-type">boolean</span> )</span> </h3>
  174. <div class="method">
  175. <div class="description">
  176. <p>Performs the SSAO pass.</p>
  177. </div>
  178. <table class="params">
  179. <tbody>
  180. <tr>
  181. <td class="name">
  182. <strong>renderer</strong>
  183. </td>
  184. <td class="description last">
  185. <p>The renderer.</p>
  186. </td>
  187. </tr>
  188. <tr>
  189. <td class="name">
  190. <strong>writeBuffer</strong>
  191. </td>
  192. <td class="description last">
  193. <p>The write buffer. This buffer is intended as the rendering
  194. destination for the pass.</p>
  195. </td>
  196. </tr>
  197. <tr>
  198. <td class="name">
  199. <strong>readBuffer</strong>
  200. </td>
  201. <td class="description last">
  202. <p>The read buffer. The pass can access the result from the
  203. previous pass from this buffer.</p>
  204. </td>
  205. </tr>
  206. <tr>
  207. <td class="name">
  208. <strong>deltaTime</strong>
  209. </td>
  210. <td class="description last">
  211. <p>The delta time in seconds.</p>
  212. </td>
  213. </tr>
  214. <tr>
  215. <td class="name">
  216. <strong>maskActive</strong>
  217. </td>
  218. <td class="description last">
  219. <p>Whether masking is active or not.</p>
  220. </td>
  221. </tr>
  222. </tbody>
  223. </table>
  224. <dl class="details">
  225. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#render">Pass#render</a></dt>
  226. </dl>
  227. </div>
  228. <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>
  229. <div class="method">
  230. <div class="description">
  231. <p>Sets the size of the pass.</p>
  232. </div>
  233. <table class="params">
  234. <tbody>
  235. <tr>
  236. <td class="name">
  237. <strong>width</strong>
  238. </td>
  239. <td class="description last">
  240. <p>The width to set.</p>
  241. </td>
  242. </tr>
  243. <tr>
  244. <td class="name">
  245. <strong>height</strong>
  246. </td>
  247. <td class="description last">
  248. <p>The height to set.</p>
  249. </td>
  250. </tr>
  251. </tbody>
  252. </table>
  253. <dl class="details">
  254. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#setSize">Pass#setSize</a></dt>
  255. </dl>
  256. </div>
  257. <h2 class="subsection-title">Source</h2>
  258. <p>
  259. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/postprocessing/SSAOPass.js" translate="no" target="_blank" rel="noopener">examples/jsm/postprocessing/SSAOPass.js</a>
  260. </p>
  261. </article>
  262. </section>
  263. <script src="../scripts/linenumber.js"></script>
  264. <script src="../scripts/page.js"></script>
  265. </body>
  266. </html>
粤ICP备19079148号