SSAOPass.html 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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">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">Scene</span>, camera : <span class="param-type">Camera</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"><code>scene</code></td>
  39. <td class="description last"><p>The scene to compute the AO for.</p></td>
  40. </tr>
  41. <tr>
  42. <td class="name"><code>camera</code></td>
  43. <td class="description last"><p>The camera.</p></td>
  44. </tr>
  45. <tr>
  46. <td class="name"><code>width</code></td>
  47. <td class="description last"><p>The width of the effect.<br/>Default is <code>512</code>.</p></td>
  48. </tr>
  49. <tr>
  50. <td class="name"><code>height</code></td>
  51. <td class="description last"><p>The height of the effect.<br/>Default is <code>512</code>.</p></td>
  52. </tr>
  53. <tr>
  54. <td class="name"><code>kernelSize</code></td>
  55. <td class="description last"><p>The kernel size.<br/>Default is <code>32</code>.</p></td>
  56. </tr>
  57. </tbody>
  58. </table>
  59. </div>
  60. </div>
  61. <h2 class="subsection-title">Properties</h2>
  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="height" translate="no">.<a href="#height">height</a><span class="type-signature"> : number</span> </h3>
  79. <div class="description">
  80. <p>The height of the effect.<br/>Default is <code>512</code>.</p>
  81. </div>
  82. </div>
  83. <div class="member">
  84. <h3 class="name" id="kernelRadius" translate="no">.<a href="#kernelRadius">kernelRadius</a><span class="type-signature"> : number</span> </h3>
  85. <div class="description">
  86. <p>The kernel radius controls how wide the
  87. AO spreads.<br/>Default is <code>8</code>.</p>
  88. </div>
  89. </div>
  90. <div class="member">
  91. <h3 class="name" id="maxDistance" translate="no">.<a href="#maxDistance">maxDistance</a><span class="type-signature"> : number</span> </h3>
  92. <div class="description">
  93. <p>Defines the maximum distance that should be
  94. affected by the AO.<br/>Default is <code>0.1</code>.</p>
  95. </div>
  96. </div>
  97. <div class="member">
  98. <h3 class="name" id="minDistance" translate="no">.<a href="#minDistance">minDistance</a><span class="type-signature"> : number</span> </h3>
  99. <div class="description">
  100. <p>Defines the minimum distance that should be
  101. affected by the AO.<br/>Default is <code>0.005</code>.</p>
  102. </div>
  103. </div>
  104. <div class="member">
  105. <h3 class="name" id="needsSwap" translate="no">.<a href="#needsSwap">needsSwap</a><span class="type-signature"> : boolean</span> </h3>
  106. <div class="description">
  107. <p>Overwritten to disable the swap.<br/>Default is <code>false</code>.</p>
  108. </div>
  109. <dl class="details">
  110. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#needsSwap">Pass#needsSwap</a></dt>
  111. </dl>
  112. </div>
  113. <div class="member">
  114. <h3 class="name" id="output" translate="no">.<a href="#output">output</a><span class="type-signature"> : number</span> </h3>
  115. <div class="description">
  116. <p>The output configuration.<br/>Default is <code>0</code>.</p>
  117. </div>
  118. </div>
  119. <div class="member">
  120. <h3 class="name" id="scene" translate="no">.<a href="#scene">scene</a><span class="type-signature"> : <a href="Scene.html">Scene</a></span> </h3>
  121. <div class="description">
  122. <p>The scene to render the AO for.</p>
  123. </div>
  124. </div>
  125. <div class="member">
  126. <h3 class="name" id="width" translate="no">.<a href="#width">width</a><span class="type-signature"> : number</span> </h3>
  127. <div class="description">
  128. <p>The width of the effect.<br/>Default is <code>512</code>.</p>
  129. </div>
  130. </div>
  131. <h2 class="subsection-title">Methods</h2>
  132. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  133. <div class="method">
  134. <div class="description">
  135. <p>Frees the GPU-related resources allocated by this instance. Call this
  136. method whenever the pass is no longer used in your app.</p>
  137. </div>
  138. <dl class="details">
  139. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#dispose">Pass#dispose</a></dt>
  140. </dl>
  141. </div>
  142. <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>
  143. <div class="method">
  144. <div class="description">
  145. <p>Performs the SSAO pass.</p>
  146. </div>
  147. <table class="params">
  148. <tbody>
  149. <tr>
  150. <td class="name"><code>renderer</code></td>
  151. <td class="description last"><p>The renderer.</p></td>
  152. </tr>
  153. <tr>
  154. <td class="name"><code>writeBuffer</code></td>
  155. <td class="description last"><p>The write buffer. This buffer is intended as the rendering
  156. destination for the pass.</p></td>
  157. </tr>
  158. <tr>
  159. <td class="name"><code>readBuffer</code></td>
  160. <td class="description last"><p>The read buffer. The pass can access the result from the
  161. previous pass from this buffer.</p></td>
  162. </tr>
  163. <tr>
  164. <td class="name"><code>deltaTime</code></td>
  165. <td class="description last"><p>The delta time in seconds.</p></td>
  166. </tr>
  167. <tr>
  168. <td class="name"><code>maskActive</code></td>
  169. <td class="description last"><p>Whether masking is active or not.</p></td>
  170. </tr>
  171. </tbody>
  172. </table>
  173. <dl class="details">
  174. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#render">Pass#render</a></dt>
  175. </dl>
  176. </div>
  177. <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>
  178. <div class="method">
  179. <div class="description">
  180. <p>Sets the size of the pass.</p>
  181. </div>
  182. <table class="params">
  183. <tbody>
  184. <tr>
  185. <td class="name"><code>width</code></td>
  186. <td class="description last"><p>The width to set.</p></td>
  187. </tr>
  188. <tr>
  189. <td class="name"><code>height</code></td>
  190. <td class="description last"><p>The height to set.</p></td>
  191. </tr>
  192. </tbody>
  193. </table>
  194. <dl class="details">
  195. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#setSize">Pass#setSize</a></dt>
  196. </dl>
  197. </div>
  198. <h2 class="subsection-title">Source</h2>
  199. <p>
  200. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/postprocessing/SSAOPass.js" target="_blank" rel="noopener" translate="no">examples/jsm/postprocessing/SSAOPass.js</a>
  201. </p>
  202. </article>
  203. </section>
  204. <script src="../scripts/linenumber.js"></script>
  205. <script src="../scripts/page.js"></script>
  206. </body>
  207. </html>
粤ICP备19079148号