DepthOfFieldNode.html 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>DepthOfFieldNode - 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">DepthOfFieldNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Post processing node for creating depth of field (DOF) effect.</p>
  17. <p>References:</p>
  18. <ul>
  19. <li><a href="https://pixelmischiefblog.wordpress.com/2016/11/25/bokeh-depth-of-field/" target="_blank" rel="noopener">https://pixelmischiefblog.wordpress.com/2016/11/25/bokeh-depth-of-field/</a></li>
  20. <li><a href="https://www.adriancourreges.com/blog/2016/09/09/doom-2016-graphics-study/" target="_blank" rel="noopener">https://www.adriancourreges.com/blog/2016/09/09/doom-2016-graphics-study/</a></li>
  21. </ul></div>
  22. </header>
  23. <article>
  24. <h2 class="subsection-title">Import</h2>
  25. <p><span translate="no">DepthOfFieldNode</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>
  26. <pre><code class="language-js">import { dof } from 'three/addons/tsl/display/DepthOfFieldNode.js';</code></pre>
  27. <div class="container-overview">
  28. <h2>Constructor</h2>
  29. <h3 class="name name-method" id="DepthOfFieldNode" translate="no">new <a href="#DepthOfFieldNode">DepthOfFieldNode</a><span class="signature">( textureNode : <span class="param-type"><a href="TextureNode.html">TextureNode</a></span>, viewZNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;float></span>, focusDistanceNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;float></span>, focalLengthNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;float></span>, bokehScaleNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;float></span> )</span> </h3>
  30. <div class="method">
  31. <div class="description">
  32. <p>Constructs a new DOF node.</p>
  33. </div>
  34. <table class="params">
  35. <tbody>
  36. <tr>
  37. <td class="name">
  38. <strong>textureNode</strong>
  39. </td>
  40. <td class="description last">
  41. <p>The texture node that represents the input of the effect.</p>
  42. </td>
  43. </tr>
  44. <tr>
  45. <td class="name">
  46. <strong>viewZNode</strong>
  47. </td>
  48. <td class="description last">
  49. <p>Represents the viewZ depth values of the scene.</p>
  50. </td>
  51. </tr>
  52. <tr>
  53. <td class="name">
  54. <strong>focusDistanceNode</strong>
  55. </td>
  56. <td class="description last">
  57. <p>Defines the effect's focus which is the distance along the camera's look direction in world units.</p>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td class="name">
  62. <strong>focalLengthNode</strong>
  63. </td>
  64. <td class="description last">
  65. <p>How far an object can be from the focal plane before it goes completely out-of-focus in world units.</p>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td class="name">
  70. <strong>bokehScaleNode</strong>
  71. </td>
  72. <td class="description last">
  73. <p>A unitless value for artistic purposes to adjust the size of the bokeh.</p>
  74. </td>
  75. </tr>
  76. </tbody>
  77. </table>
  78. </div>
  79. </div>
  80. <h2 class="subsection-title">Properties</h2>
  81. <div class="member">
  82. <h3 class="name" id="bokehScaleNode" translate="no">.<a href="#bokehScaleNode">bokehScaleNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  83. <div class="description">
  84. <p>A unitless value for artistic purposes to adjust the size of the bokeh.</p>
  85. </div>
  86. </div>
  87. <div class="member">
  88. <h3 class="name" id="focalLengthNode" translate="no">.<a href="#focalLengthNode">focalLengthNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  89. <div class="description">
  90. <p>How far an object can be from the focal plane before it goes completely out-of-focus in world units.</p>
  91. </div>
  92. </div>
  93. <div class="member">
  94. <h3 class="name" id="focusDistanceNode" translate="no">.<a href="#focusDistanceNode">focusDistanceNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  95. <div class="description">
  96. <p>Defines the effect's focus which is the distance along the camera's look direction in world units.</p>
  97. </div>
  98. </div>
  99. <div class="member">
  100. <h3 class="name" id="textureNode" translate="no">.<a href="#textureNode">textureNode</a><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  101. <div class="description">
  102. <p>The texture node that represents the input of the effect.</p>
  103. </div>
  104. </div>
  105. <div class="member">
  106. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  107. <div class="description">
  108. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node updates
  109. its internal uniforms once per frame in <code>updateBefore()</code>.</p>
  110. <p>Default is <code>'frame'</code>.</p>
  111. </div>
  112. <dl class="details">
  113. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  114. </dl>
  115. </div>
  116. <div class="member">
  117. <h3 class="name" id="viewZNode" translate="no">.<a href="#viewZNode">viewZNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  118. <div class="description">
  119. <p>Represents the viewZ depth values of the scene.</p>
  120. </div>
  121. </div>
  122. <h2 class="subsection-title">Methods</h2>
  123. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  124. <div class="method">
  125. <div class="description">
  126. <p>Frees internal resources. This method should be called
  127. when the effect is no longer required.</p>
  128. </div>
  129. <dl class="details">
  130. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  131. </dl>
  132. </div>
  133. <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>
  134. <div class="method">
  135. <div class="description">
  136. <p>Returns the result of the effect as a texture node.</p>
  137. </div>
  138. <dl class="details">
  139. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  140. </dl>
  141. </div>
  142. <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>
  143. <div class="method">
  144. <div class="description">
  145. <p>Sets the size of the effect.</p>
  146. </div>
  147. <table class="params">
  148. <tbody>
  149. <tr>
  150. <td class="name">
  151. <strong>width</strong>
  152. </td>
  153. <td class="description last">
  154. <p>The width of the effect.</p>
  155. </td>
  156. </tr>
  157. <tr>
  158. <td class="name">
  159. <strong>height</strong>
  160. </td>
  161. <td class="description last">
  162. <p>The height of the effect.</p>
  163. </td>
  164. </tr>
  165. </tbody>
  166. </table>
  167. </div>
  168. <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"> : ShaderCallNodeInternal</span> </h3>
  169. <div class="method">
  170. <div class="description">
  171. <p>This method is used to setup the effect's TSL code.</p>
  172. </div>
  173. <table class="params">
  174. <tbody>
  175. <tr>
  176. <td class="name">
  177. <strong>builder</strong>
  178. </td>
  179. <td class="description last">
  180. <p>The current node builder.</p>
  181. </td>
  182. </tr>
  183. </tbody>
  184. </table>
  185. <dl class="details">
  186. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  187. </dl>
  188. </div>
  189. <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>
  190. <div class="method">
  191. <div class="description">
  192. <p>This method is used to update the effect's uniforms once per frame.</p>
  193. </div>
  194. <table class="params">
  195. <tbody>
  196. <tr>
  197. <td class="name">
  198. <strong>frame</strong>
  199. </td>
  200. <td class="description last">
  201. <p>The current node frame.</p>
  202. </td>
  203. </tr>
  204. </tbody>
  205. </table>
  206. <dl class="details">
  207. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</a></dt>
  208. </dl>
  209. </div>
  210. <h2 class="subsection-title">Source</h2>
  211. <p>
  212. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/display/DepthOfFieldNode.js" translate="no" target="_blank" rel="noopener">examples/jsm/tsl/display/DepthOfFieldNode.js</a>
  213. </p>
  214. </article>
  215. </section>
  216. <script src="../scripts/linenumber.js"></script>
  217. <script src="../scripts/page.js"></script>
  218. </body>
  219. </html>
粤ICP备19079148号