ShadowNode.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ShadowNode - 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="ShadowBaseNode.html">ShadowBaseNode</a> → </p>
  13. <h1 translate="no">ShadowNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Represents the default shadow implementation for lighting nodes.</p></div>
  17. </header>
  18. <article>
  19. <div class="container-overview">
  20. <h2>Constructor</h2>
  21. <h3 class="name name-method" id="ShadowNode" translate="no">new <a href="#ShadowNode">ShadowNode</a><span class="signature">( light : <span class="param-type">Light</span>, shadow : <span class="param-type">LightShadow</span> )</span> </h3>
  22. <div class="method">
  23. <div class="description">
  24. <p>Constructs a new shadow node.</p>
  25. </div>
  26. <table class="params">
  27. <tbody>
  28. <tr>
  29. <td class="name"><code>light</code></td>
  30. <td class="description last"><p>The shadow casting light.</p></td>
  31. </tr>
  32. <tr>
  33. <td class="name"><code>shadow</code></td>
  34. <td class="description last"><p>An optional light shadow.<br/>Default is <code>null</code>.</p></td>
  35. </tr>
  36. </tbody>
  37. </table>
  38. </div>
  39. </div>
  40. <h2 class="subsection-title">Properties</h2>
  41. <div class="member">
  42. <h3 class="name" id="depthLayer" translate="no">.<a href="#depthLayer">depthLayer</a><span class="type-signature"> : number</span> <span class="type-signature">(readonly) </span></h3>
  43. <div class="description">
  44. <p>This index can be used when overriding setupRenderTarget with a RenderTarget Array to specify the depth layer.<br/>Default is <code>true</code>.</p>
  45. </div>
  46. </div>
  47. <div class="member">
  48. <h3 class="name" id="isShadowNode" translate="no">.<a href="#isShadowNode">isShadowNode</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  49. <div class="description">
  50. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  51. </div>
  52. </div>
  53. <div class="member">
  54. <h3 class="name" id="shadow" translate="no">.<a href="#shadow">shadow</a><span class="type-signature"> : <a href="LightShadow.html">LightShadow</a></span> </h3>
  55. <div class="description">
  56. <p>The light shadow which defines the properties light's
  57. shadow.<br/>Default is <code>null</code>.</p>
  58. </div>
  59. </div>
  60. <div class="member">
  61. <h3 class="name" id="shadowMap" translate="no">.<a href="#shadowMap">shadowMap</a><span class="type-signature"> : <a href="RenderTarget.html">RenderTarget</a></span> </h3>
  62. <div class="description">
  63. <p>A reference to the shadow map which is a render target.<br/>Default is <code>null</code>.</p>
  64. </div>
  65. </div>
  66. <div class="member">
  67. <h3 class="name" id="vsmMaterialHorizontal" translate="no">.<a href="#vsmMaterialHorizontal">vsmMaterialHorizontal</a><span class="type-signature"> : <a href="NodeMaterial.html">NodeMaterial</a></span> </h3>
  68. <div class="description">
  69. <p>Only relevant for VSM shadows. Node material which
  70. is used to render the second VSM pass.<br/>Default is <code>null</code>.</p>
  71. </div>
  72. </div>
  73. <div class="member">
  74. <h3 class="name" id="vsmMaterialVertical" translate="no">.<a href="#vsmMaterialVertical">vsmMaterialVertical</a><span class="type-signature"> : <a href="NodeMaterial.html">NodeMaterial</a></span> </h3>
  75. <div class="description">
  76. <p>Only relevant for VSM shadows. Node material which
  77. is used to render the first VSM pass.<br/>Default is <code>null</code>.</p>
  78. </div>
  79. </div>
  80. <div class="member">
  81. <h3 class="name" id="vsmShadowMapHorizontal" translate="no">.<a href="#vsmShadowMapHorizontal">vsmShadowMapHorizontal</a><span class="type-signature"> : <a href="RenderTarget.html">RenderTarget</a></span> </h3>
  82. <div class="description">
  83. <p>Only relevant for VSM shadows. Render target for the
  84. second VSM render pass.<br/>Default is <code>null</code>.</p>
  85. </div>
  86. </div>
  87. <div class="member">
  88. <h3 class="name" id="vsmShadowMapVertical" translate="no">.<a href="#vsmShadowMapVertical">vsmShadowMapVertical</a><span class="type-signature"> : <a href="RenderTarget.html">RenderTarget</a></span> </h3>
  89. <div class="description">
  90. <p>Only relevant for VSM shadows. Render target for the
  91. first VSM render pass.<br/>Default is <code>null</code>.</p>
  92. </div>
  93. </div>
  94. <h2 class="subsection-title">Methods</h2>
  95. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  96. <div class="method">
  97. <div class="description">
  98. <p>Frees the internal resources of this shadow node.</p>
  99. </div>
  100. <dl class="details">
  101. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="ShadowBaseNode.html#dispose">ShadowBaseNode#dispose</a></dt>
  102. </dl>
  103. </div>
  104. <h3 class="name name-method" id="getShadowFilterFn" translate="no">.<a href="#getShadowFilterFn">getShadowFilterFn</a><span class="signature">( type : <span class="param-type">number</span> )</span><span class="type-signature"> : function</span> </h3>
  105. <div class="method">
  106. <div class="description">
  107. <p>Returns the shadow filtering function for the given shadow type.</p>
  108. </div>
  109. <table class="params">
  110. <tbody>
  111. <tr>
  112. <td class="name"><code>type</code></td>
  113. <td class="description last"><p>The shadow type.</p></td>
  114. </tr>
  115. </tbody>
  116. </table>
  117. <dl class="details">
  118. <dt class="tag-returns"><strong>Returns:</strong> The filtering function.</dt>
  119. </dl>
  120. </div>
  121. <h3 class="name name-method" id="renderShadow" translate="no">.<a href="#renderShadow">renderShadow</a><span class="signature">( frame : <span class="param-type">NodeFrame</span> )</span> </h3>
  122. <div class="method">
  123. <div class="description">
  124. <p>Renders the shadow. The logic of this function could be included
  125. into <a href="ShadowNode.html#updateShadow">ShadowNode#updateShadow</a> however more specialized shadow
  126. nodes might require a custom shadow map rendering. By having a
  127. dedicated method, it's easier to overwrite the default behavior.</p>
  128. </div>
  129. <table class="params">
  130. <tbody>
  131. <tr>
  132. <td class="name"><code>frame</code></td>
  133. <td class="description last"><p>A reference to the current node frame.</p></td>
  134. </tr>
  135. </tbody>
  136. </table>
  137. </div>
  138. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : ShaderCallNodeInternal</span> </h3>
  139. <div class="method">
  140. <div class="description">
  141. <p>The implementation performs the setup of the output node. An output is only
  142. produces if shadow mapping is globally enabled in the renderer.</p>
  143. </div>
  144. <table class="params">
  145. <tbody>
  146. <tr>
  147. <td class="name"><code>builder</code></td>
  148. <td class="description last"><p>A reference to the current node builder.</p></td>
  149. </tr>
  150. </tbody>
  151. </table>
  152. <dl class="details">
  153. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="ShadowBaseNode.html#setup">ShadowBaseNode#setup</a></dt>
  154. </dl>
  155. <dl class="details">
  156. <dt class="tag-returns"><strong>Returns:</strong> The output node.</dt>
  157. </dl>
  158. </div>
  159. <h3 class="name name-method" id="setupShadow" translate="no">.<a href="#setupShadow">setupShadow</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  160. <div class="method">
  161. <div class="description">
  162. <p>Setups the shadow output node.</p>
  163. </div>
  164. <table class="params">
  165. <tbody>
  166. <tr>
  167. <td class="name"><code>builder</code></td>
  168. <td class="description last"><p>A reference to the current node builder.</p></td>
  169. </tr>
  170. </tbody>
  171. </table>
  172. <dl class="details">
  173. <dt class="tag-returns"><strong>Returns:</strong> The shadow output node.</dt>
  174. </dl>
  175. </div>
  176. <h3 class="name name-method" id="setupShadowCoord" translate="no">.<a href="#setupShadowCoord">setupShadowCoord</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span>, shadowPosition : <span class="param-type">Node.&lt;vec3></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  177. <div class="method">
  178. <div class="description">
  179. <p>Setups the shadow coordinates.</p>
  180. </div>
  181. <table class="params">
  182. <tbody>
  183. <tr>
  184. <td class="name"><code>builder</code></td>
  185. <td class="description last"><p>A reference to the current node builder.</p></td>
  186. </tr>
  187. <tr>
  188. <td class="name"><code>shadowPosition</code></td>
  189. <td class="description last"><p>A node representing the shadow position.</p></td>
  190. </tr>
  191. </tbody>
  192. </table>
  193. <dl class="details">
  194. <dt class="tag-returns"><strong>Returns:</strong> The shadow coordinates.</dt>
  195. </dl>
  196. </div>
  197. <h3 class="name name-method" id="setupShadowFilter" translate="no">.<a href="#setupShadowFilter">setupShadowFilter</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span>, inputs : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  198. <div class="method">
  199. <div class="description">
  200. <p>Setups the shadow filtering.</p>
  201. </div>
  202. <table class="params">
  203. <tbody>
  204. <tr>
  205. <td class="name"><code>builder</code></td>
  206. <td class="description last"><p>A reference to the current node builder.</p></td>
  207. </tr>
  208. <tr>
  209. <td class="name"><code>inputs</code></td>
  210. <td class="description last"><p>A configuration object that defines the shadow filtering.</p>
  211. <h6>Properties</h6>
  212. <table class="params">
  213. <tbody>
  214. <tr>
  215. <td class="name"><code>filterFn</code></td>
  216. <td class="description last"><p>This function defines the filtering type of the shadow map e.g. PCF.</p></td>
  217. </tr>
  218. <tr>
  219. <td class="name"><code>depthTexture</code></td>
  220. <td class="description last"><p>A reference to the shadow map's texture data.</p></td>
  221. </tr>
  222. <tr>
  223. <td class="name"><code>shadowCoord</code></td>
  224. <td class="description last"><p>Shadow coordinates which are used to sample from the shadow map.</p></td>
  225. </tr>
  226. <tr>
  227. <td class="name"><code>shadow</code></td>
  228. <td class="description last"><p>The light shadow.</p></td>
  229. </tr>
  230. </tbody>
  231. </table>
  232. </td>
  233. </tr>
  234. </tbody>
  235. </table>
  236. <dl class="details">
  237. <dt class="tag-returns"><strong>Returns:</strong> The result node of the shadow filtering.</dt>
  238. </dl>
  239. </div>
  240. <h3 class="name name-method" id="updateBefore" translate="no">.<a href="#updateBefore">updateBefore</a><span class="signature">( frame : <span class="param-type">NodeFrame</span> )</span> </h3>
  241. <div class="method">
  242. <div class="description">
  243. <p>The implementation performs the update of the shadow map if necessary.</p>
  244. </div>
  245. <table class="params">
  246. <tbody>
  247. <tr>
  248. <td class="name"><code>frame</code></td>
  249. <td class="description last"><p>A reference to the current node frame.</p></td>
  250. </tr>
  251. </tbody>
  252. </table>
  253. <dl class="details">
  254. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="ShadowBaseNode.html#updateBefore">ShadowBaseNode#updateBefore</a></dt>
  255. </dl>
  256. </div>
  257. <h3 class="name name-method" id="updateShadow" translate="no">.<a href="#updateShadow">updateShadow</a><span class="signature">( frame : <span class="param-type">NodeFrame</span> )</span> </h3>
  258. <div class="method">
  259. <div class="description">
  260. <p>Updates the shadow.</p>
  261. </div>
  262. <table class="params">
  263. <tbody>
  264. <tr>
  265. <td class="name"><code>frame</code></td>
  266. <td class="description last"><p>A reference to the current node frame.</p></td>
  267. </tr>
  268. </tbody>
  269. </table>
  270. </div>
  271. <h3 class="name name-method" id="vsmPass" translate="no">.<a href="#vsmPass">vsmPass</a><span class="signature">( renderer : <span class="param-type">Renderer</span> )</span> </h3>
  272. <div class="method">
  273. <div class="description">
  274. <p>For VSM additional render passes are required.</p>
  275. </div>
  276. <table class="params">
  277. <tbody>
  278. <tr>
  279. <td class="name"><code>renderer</code></td>
  280. <td class="description last"><p>A reference to the current renderer.</p></td>
  281. </tr>
  282. </tbody>
  283. </table>
  284. </div>
  285. <h2 class="subsection-title">Source</h2>
  286. <p>
  287. <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/lighting/ShadowNode.js" target="_blank" rel="noopener" translate="no">src/nodes/lighting/ShadowNode.js</a>
  288. </p>
  289. </article>
  290. </section>
  291. <script src="../scripts/linenumber.js"></script>
  292. <script src="../scripts/page.js"></script>
  293. </body>
  294. </html>
粤ICP备19079148号