BloomNode.html 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>BloomNode - 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="EventDispatcher.html">EventDispatcher</a> → <a href="Node.html">Node</a> → <a href="TempNode.html">TempNode</a> → </p>
  13. <h1 translate="no">BloomNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Post processing node for creating a bloom effect.</p>
  17. <pre><code class="language-js">const renderPipeline = new THREE.RenderPipeline( renderer );
  18. const scenePass = pass( scene, camera );
  19. const scenePassColor = scenePass.getTextureNode( 'output' );
  20. const bloomPass = bloom( scenePassColor );
  21. renderPipeline.outputNode = scenePassColor.add( bloomPass );
  22. </code></pre>
  23. <p>By default, the node affects the entire image. For a selective bloom,
  24. use the <code>emissive</code> material property to control which objects should
  25. contribute to bloom or not. This can be achieved via MRT.</p>
  26. <pre><code class="language-js">const renderPipeline = new THREE.RenderPipeline( renderer );
  27. const scenePass = pass( scene, camera );
  28. scenePass.setMRT( mrt( {
  29. output,
  30. emissive
  31. } ) );
  32. const scenePassColor = scenePass.getTextureNode( 'output' );
  33. const emissivePass = scenePass.getTextureNode( 'emissive' );
  34. const bloomPass = bloom( emissivePass );
  35. renderPipeline.outputNode = scenePassColor.add( bloomPass );
  36. </code></pre></div>
  37. </header>
  38. <article>
  39. <h2 class="subsection-title">Import</h2>
  40. <p><span translate="no">BloomNode</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>
  41. <pre><code class="language-js">import { bloom } from 'three/addons/tsl/display/BloomNode.js';</code></pre>
  42. <div class="container-overview">
  43. <h2>Constructor</h2>
  44. <h3 class="name name-method" id="BloomNode" translate="no">new <a href="#BloomNode">BloomNode</a><span class="signature">( inputNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;vec4></span>, strength : <span class="param-type">number</span>, radius : <span class="param-type">number</span>, threshold : <span class="param-type">number</span> )</span> </h3>
  45. <div class="method">
  46. <div class="description">
  47. <p>Constructs a new bloom node.</p>
  48. </div>
  49. <table class="params">
  50. <tbody>
  51. <tr>
  52. <td class="name">
  53. <strong translate="no">inputNode</strong>
  54. </td>
  55. <td class="description last">
  56. <p>The node that represents the input of the effect.</p>
  57. </td>
  58. </tr>
  59. <tr>
  60. <td class="name">
  61. <strong translate="no">strength</strong>
  62. </td>
  63. <td class="description last">
  64. <p>The strength of the bloom.</p>
  65. <p>Default is <code>1</code>.</p>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td class="name">
  70. <strong translate="no">radius</strong>
  71. </td>
  72. <td class="description last">
  73. <p>The radius of the bloom.</p>
  74. <p>Default is <code>0</code>.</p>
  75. </td>
  76. </tr>
  77. <tr>
  78. <td class="name">
  79. <strong translate="no">threshold</strong>
  80. </td>
  81. <td class="description last">
  82. <p>The luminance threshold limits which bright areas contribute to the bloom effect.</p>
  83. <p>Default is <code>0</code>.</p>
  84. </td>
  85. </tr>
  86. </tbody>
  87. </table>
  88. </div>
  89. </div>
  90. <h2 class="subsection-title">Properties</h2>
  91. <div class="member">
  92. <h3 class="name" id="inputNode" translate="no">.<a href="#inputNode">inputNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  93. <div class="description">
  94. <p>The node that represents the input of the effect.</p>
  95. </div>
  96. </div>
  97. <div class="member">
  98. <h3 class="name" id="radius" translate="no">.<a href="#radius">radius</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  99. <div class="description">
  100. <p>The radius of the bloom. Must be in the range <code>[0,1]</code>.</p>
  101. </div>
  102. </div>
  103. <div class="member">
  104. <h3 class="name" id="smoothWidth" translate="no">.<a href="#smoothWidth">smoothWidth</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  105. <div class="description">
  106. <p>Can be used to tweak the extracted luminance from the scene.</p>
  107. </div>
  108. </div>
  109. <div class="member">
  110. <h3 class="name" id="strength" translate="no">.<a href="#strength">strength</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  111. <div class="description">
  112. <p>The strength of the bloom.</p>
  113. </div>
  114. </div>
  115. <div class="member">
  116. <h3 class="name" id="threshold" translate="no">.<a href="#threshold">threshold</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  117. <div class="description">
  118. <p>The luminance threshold limits which bright areas contribute to the bloom effect.</p>
  119. </div>
  120. </div>
  121. <div class="member">
  122. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  123. <div class="description">
  124. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node renders
  125. its effect once per frame in <code>updateBefore()</code>.</p>
  126. <p>Default is <code>'frame'</code>.</p>
  127. </div>
  128. <dl class="details">
  129. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  130. </dl>
  131. </div>
  132. <h2 class="subsection-title">Methods</h2>
  133. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  134. <div class="method">
  135. <div class="description">
  136. <p>Frees internal resources. This method should be called
  137. when the effect is no longer required.</p>
  138. </div>
  139. <dl class="details">
  140. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  141. </dl>
  142. </div>
  143. <h3 class="name name-method" id="getTextureNode" translate="no">.<a href="#getTextureNode">getTextureNode</a><span class="signature">()</span><span class="type-signature"> : <a href="PassTextureNode.html">PassTextureNode</a></span> </h3>
  144. <div class="method">
  145. <div class="description">
  146. <p>Returns the result of the effect as a texture node.</p>
  147. </div>
  148. <dl class="details">
  149. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  150. </dl>
  151. </div>
  152. <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>
  153. <div class="method">
  154. <div class="description">
  155. <p>Sets the size of the effect.</p>
  156. </div>
  157. <table class="params">
  158. <tbody>
  159. <tr>
  160. <td class="name">
  161. <strong translate="no">width</strong>
  162. </td>
  163. <td class="description last">
  164. <p>The width of the effect.</p>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td class="name">
  169. <strong translate="no">height</strong>
  170. </td>
  171. <td class="description last">
  172. <p>The height of the effect.</p>
  173. </td>
  174. </tr>
  175. </tbody>
  176. </table>
  177. </div>
  178. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="PassTextureNode.html">PassTextureNode</a></span> </h3>
  179. <div class="method">
  180. <div class="description">
  181. <p>This method is used to setup the effect's TSL code.</p>
  182. </div>
  183. <table class="params">
  184. <tbody>
  185. <tr>
  186. <td class="name">
  187. <strong translate="no">builder</strong>
  188. </td>
  189. <td class="description last">
  190. <p>The current node builder.</p>
  191. </td>
  192. </tr>
  193. </tbody>
  194. </table>
  195. <dl class="details">
  196. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  197. </dl>
  198. </div>
  199. <h3 class="name name-method" id="updateBefore" translate="no">.<a href="#updateBefore">updateBefore</a><span class="signature">( frame : <span class="param-type"><a href="NodeFrame.html">NodeFrame</a></span> )</span> </h3>
  200. <div class="method">
  201. <div class="description">
  202. <p>This method is used to render the effect once per frame.</p>
  203. </div>
  204. <table class="params">
  205. <tbody>
  206. <tr>
  207. <td class="name">
  208. <strong translate="no">frame</strong>
  209. </td>
  210. <td class="description last">
  211. <p>The current node frame.</p>
  212. </td>
  213. </tr>
  214. </tbody>
  215. </table>
  216. <dl class="details">
  217. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</a></dt>
  218. </dl>
  219. </div>
  220. <h2 class="subsection-title">Source</h2>
  221. <p>
  222. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/display/BloomNode.js" translate="no" target="_blank" rel="noopener">examples/jsm/tsl/display/BloomNode.js</a>
  223. </p>
  224. </article>
  225. </section>
  226. <script src="../scripts/linenumber.js"></script>
  227. <script src="../scripts/page.js"></script>
  228. </body>
  229. </html>
粤ICP备19079148号