1
0

ShaderPass.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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">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 | ShaderMaterial</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"><code>shader</code></td>
  39. <td class="description last"><p>A shader object holding vertex and fragment shader as well as
  40. defines and uniforms. It's also valid to pass a custom shader material.</p></td>
  41. </tr>
  42. <tr>
  43. <td class="name"><code>textureID</code></td>
  44. <td class="description last"><p>The name of the texture uniform that should sample
  45. the read buffer.<br/>Default is <code>'tDiffuse'</code>.</p></td>
  46. </tr>
  47. </tbody>
  48. </table>
  49. </div>
  50. </div>
  51. <h2 class="subsection-title">Properties</h2>
  52. <div class="member">
  53. <h3 class="name" id="material" translate="no">.<a href="#material">material</a><span class="type-signature"> : <a href="ShaderMaterial.html">ShaderMaterial</a></span> </h3>
  54. <div class="description">
  55. <p>The pass material.</p>
  56. </div>
  57. </div>
  58. <div class="member">
  59. <h3 class="name" id="textureID" translate="no">.<a href="#textureID">textureID</a><span class="type-signature"> : string</span> </h3>
  60. <div class="description">
  61. <p>The name of the texture uniform that should sample the read buffer.<br/>Default is <code>'tDiffuse'</code>.</p>
  62. </div>
  63. </div>
  64. <div class="member">
  65. <h3 class="name" id="uniforms" translate="no">.<a href="#uniforms">uniforms</a><span class="type-signature"> : Object</span> </h3>
  66. <div class="description">
  67. <p>The pass uniforms.</p>
  68. </div>
  69. </div>
  70. <h2 class="subsection-title">Methods</h2>
  71. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  72. <div class="method">
  73. <div class="description">
  74. <p>Frees the GPU-related resources allocated by this instance. Call this
  75. method whenever the pass is no longer used in your app.</p>
  76. </div>
  77. <dl class="details">
  78. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#dispose">Pass#dispose</a></dt>
  79. </dl>
  80. </div>
  81. <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>
  82. <div class="method">
  83. <div class="description">
  84. <p>Performs the shader pass.</p>
  85. </div>
  86. <table class="params">
  87. <tbody>
  88. <tr>
  89. <td class="name"><code>renderer</code></td>
  90. <td class="description last"><p>The renderer.</p></td>
  91. </tr>
  92. <tr>
  93. <td class="name"><code>writeBuffer</code></td>
  94. <td class="description last"><p>The write buffer. This buffer is intended as the rendering
  95. destination for the pass.</p></td>
  96. </tr>
  97. <tr>
  98. <td class="name"><code>readBuffer</code></td>
  99. <td class="description last"><p>The read buffer. The pass can access the result from the
  100. previous pass from this buffer.</p></td>
  101. </tr>
  102. <tr>
  103. <td class="name"><code>deltaTime</code></td>
  104. <td class="description last"><p>The delta time in seconds.</p></td>
  105. </tr>
  106. <tr>
  107. <td class="name"><code>maskActive</code></td>
  108. <td class="description last"><p>Whether masking is active or not.</p></td>
  109. </tr>
  110. </tbody>
  111. </table>
  112. <dl class="details">
  113. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#render">Pass#render</a></dt>
  114. </dl>
  115. </div>
  116. <h2 class="subsection-title">Source</h2>
  117. <p>
  118. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/postprocessing/ShaderPass.js" target="_blank" rel="noopener" translate="no">examples/jsm/postprocessing/ShaderPass.js</a>
  119. </p>
  120. </article>
  121. </section>
  122. <script src="../scripts/linenumber.js"></script>
  123. <script src="../scripts/page.js"></script>
  124. </body>
  125. </html>
粤ICP备19079148号