BloomNode.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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="highPassFn" translate="no">.<a href="#highPassFn">highPassFn</a><span class="type-signature"> : function</span> </h3>
  93. <div class="description">
  94. <p>Can be used to inject a custom high pass filter (e.g., for anamorphic effects).</p>
  95. </div>
  96. </div>
  97. <div class="member">
  98. <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>
  99. <div class="description">
  100. <p>The node that represents the input of the effect.</p>
  101. </div>
  102. </div>
  103. <div class="member">
  104. <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>
  105. <div class="description">
  106. <p>The radius of the bloom. Must be in the range <code>[0,1]</code>.</p>
  107. </div>
  108. </div>
  109. <div class="member">
  110. <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>
  111. <div class="description">
  112. <p>Can be used to tweak the extracted luminance from the scene.</p>
  113. </div>
  114. </div>
  115. <div class="member">
  116. <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>
  117. <div class="description">
  118. <p>The strength of the bloom.</p>
  119. </div>
  120. </div>
  121. <div class="member">
  122. <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>
  123. <div class="description">
  124. <p>The luminance threshold limits which bright areas contribute to the bloom effect.</p>
  125. </div>
  126. </div>
  127. <div class="member">
  128. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  129. <div class="description">
  130. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node renders
  131. its effect once per frame in <code>updateBefore()</code>.</p>
  132. <p>Default is <code>'frame'</code>.</p>
  133. </div>
  134. <dl class="details">
  135. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  136. </dl>
  137. </div>
  138. <h2 class="subsection-title">Methods</h2>
  139. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  140. <div class="method">
  141. <div class="description">
  142. <p>Frees internal resources. This method should be called
  143. when the effect is no longer required.</p>
  144. </div>
  145. <dl class="details">
  146. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  147. </dl>
  148. </div>
  149. <h3 class="name name-method" id="getResolutionScale" translate="no">.<a href="#getResolutionScale">getResolutionScale</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  150. <div class="method">
  151. <div class="description">
  152. <p>Gets the current resolution scale of the pass.</p>
  153. </div>
  154. <dl class="details">
  155. <dt class="tag-returns"><strong>Returns:</strong> The current resolution scale. A value of <code>1</code> means full resolution.</dt>
  156. </dl>
  157. </div>
  158. <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>
  159. <div class="method">
  160. <div class="description">
  161. <p>Returns the result of the effect as a texture node.</p>
  162. </div>
  163. <dl class="details">
  164. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  165. </dl>
  166. </div>
  167. <h3 class="name name-method" id="setResolutionScale" translate="no">.<a href="#setResolutionScale">setResolutionScale</a><span class="signature">( resolutionScale : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BloomNode.html">BloomNode</a></span> </h3>
  168. <div class="method">
  169. <div class="description">
  170. <p>Sets the resolution scale for the pass.
  171. The resolution scale is a factor that is multiplied with the renderer's width and height.</p>
  172. </div>
  173. <table class="params">
  174. <tbody>
  175. <tr>
  176. <td class="name">
  177. <strong translate="no">resolutionScale</strong>
  178. </td>
  179. <td class="description last">
  180. <p>The resolution scale to set. A value of <code>1</code> means full resolution.</p>
  181. </td>
  182. </tr>
  183. </tbody>
  184. </table>
  185. <dl class="details">
  186. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  187. </dl>
  188. </div>
  189. <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>
  190. <div class="method">
  191. <div class="description">
  192. <p>Sets the size of the effect.</p>
  193. </div>
  194. <table class="params">
  195. <tbody>
  196. <tr>
  197. <td class="name">
  198. <strong translate="no">width</strong>
  199. </td>
  200. <td class="description last">
  201. <p>The width of the effect.</p>
  202. </td>
  203. </tr>
  204. <tr>
  205. <td class="name">
  206. <strong translate="no">height</strong>
  207. </td>
  208. <td class="description last">
  209. <p>The height of the effect.</p>
  210. </td>
  211. </tr>
  212. </tbody>
  213. </table>
  214. </div>
  215. <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>
  216. <div class="method">
  217. <div class="description">
  218. <p>This method is used to setup the effect's TSL code.</p>
  219. </div>
  220. <table class="params">
  221. <tbody>
  222. <tr>
  223. <td class="name">
  224. <strong translate="no">builder</strong>
  225. </td>
  226. <td class="description last">
  227. <p>The current node builder.</p>
  228. </td>
  229. </tr>
  230. </tbody>
  231. </table>
  232. <dl class="details">
  233. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  234. </dl>
  235. </div>
  236. <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>
  237. <div class="method">
  238. <div class="description">
  239. <p>This method is used to render the effect once per frame.</p>
  240. </div>
  241. <table class="params">
  242. <tbody>
  243. <tr>
  244. <td class="name">
  245. <strong translate="no">frame</strong>
  246. </td>
  247. <td class="description last">
  248. <p>The current node frame.</p>
  249. </td>
  250. </tr>
  251. </tbody>
  252. </table>
  253. <dl class="details">
  254. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</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/tsl/display/BloomNode.js" translate="no" target="_blank" rel="noopener">examples/jsm/tsl/display/BloomNode.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号