ShaderPass.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ShaderPass - 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">ShaderPass</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>This pass can be used to create a post processing effect
  17. with a raw GLSL shader object. Useful for implementing custom
  18. effects.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">const fxaaPass = new ShaderPass( FXAAShader );
  21. composer.addPass( fxaaPass );
  22. </code></pre></div>
  23. </header>
  24. <article>
  25. <h2 class="subsection-title">Import</h2>
  26. <p><span translate="no">ShaderPass</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 { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';</code></pre>
  28. <div class="container-overview">
  29. <h2>Constructor</h2>
  30. <h3 class="name name-method" id="ShaderPass" translate="no">new <a href="#ShaderPass">ShaderPass</a><span class="signature">( shader : <span class="param-type">Object | <a href="ShaderMaterial.html">ShaderMaterial</a></span>, textureID : <span class="param-type">string</span> )</span> </h3>
  31. <div class="method">
  32. <div class="description">
  33. <p>Constructs a new shader pass.</p>
  34. </div>
  35. <table class="params">
  36. <tbody>
  37. <tr>
  38. <td class="name">
  39. <strong>shader</strong>
  40. </td>
  41. <td class="description last">
  42. <p>A shader object holding vertex and fragment shader as well as
  43. defines and uniforms. It's also valid to pass a custom shader material.</p>
  44. </td>
  45. </tr>
  46. <tr>
  47. <td class="name">
  48. <strong>textureID</strong>
  49. </td>
  50. <td class="description last">
  51. <p>The name of the texture uniform that should sample
  52. the read buffer.</p>
  53. <p>Default is <code>'tDiffuse'</code>.</p>
  54. </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="material" translate="no">.<a href="#material">material</a><span class="type-signature"> : <a href="ShaderMaterial.html">ShaderMaterial</a></span> </h3>
  63. <div class="description">
  64. <p>The pass material.</p>
  65. </div>
  66. </div>
  67. <div class="member">
  68. <h3 class="name" id="textureID" translate="no">.<a href="#textureID">textureID</a><span class="type-signature"> : string</span> </h3>
  69. <div class="description">
  70. <p>The name of the texture uniform that should sample the read buffer.</p>
  71. <p>Default is <code>'tDiffuse'</code>.</p>
  72. </div>
  73. </div>
  74. <div class="member">
  75. <h3 class="name" id="uniforms" translate="no">.<a href="#uniforms">uniforms</a><span class="type-signature"> : Object</span> </h3>
  76. <div class="description">
  77. <p>The pass uniforms.</p>
  78. </div>
  79. </div>
  80. <h2 class="subsection-title">Methods</h2>
  81. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  82. <div class="method">
  83. <div class="description">
  84. <p>Frees the GPU-related resources allocated by this instance. Call this
  85. method whenever the pass is no longer used in your app.</p>
  86. </div>
  87. <dl class="details">
  88. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#dispose">Pass#dispose</a></dt>
  89. </dl>
  90. </div>
  91. <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>
  92. <div class="method">
  93. <div class="description">
  94. <p>Performs the shader pass.</p>
  95. </div>
  96. <table class="params">
  97. <tbody>
  98. <tr>
  99. <td class="name">
  100. <strong>renderer</strong>
  101. </td>
  102. <td class="description last">
  103. <p>The renderer.</p>
  104. </td>
  105. </tr>
  106. <tr>
  107. <td class="name">
  108. <strong>writeBuffer</strong>
  109. </td>
  110. <td class="description last">
  111. <p>The write buffer. This buffer is intended as the rendering
  112. destination for the pass.</p>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td class="name">
  117. <strong>readBuffer</strong>
  118. </td>
  119. <td class="description last">
  120. <p>The read buffer. The pass can access the result from the
  121. previous pass from this buffer.</p>
  122. </td>
  123. </tr>
  124. <tr>
  125. <td class="name">
  126. <strong>deltaTime</strong>
  127. </td>
  128. <td class="description last">
  129. <p>The delta time in seconds.</p>
  130. </td>
  131. </tr>
  132. <tr>
  133. <td class="name">
  134. <strong>maskActive</strong>
  135. </td>
  136. <td class="description last">
  137. <p>Whether masking is active or not.</p>
  138. </td>
  139. </tr>
  140. </tbody>
  141. </table>
  142. <dl class="details">
  143. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#render">Pass#render</a></dt>
  144. </dl>
  145. </div>
  146. <h2 class="subsection-title">Source</h2>
  147. <p>
  148. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/postprocessing/ShaderPass.js" translate="no" target="_blank" rel="noopener">examples/jsm/postprocessing/ShaderPass.js</a>
  149. </p>
  150. </article>
  151. </section>
  152. <script src="../scripts/linenumber.js"></script>
  153. <script src="../scripts/page.js"></script>
  154. </body>
  155. </html>
粤ICP备19079148号