NodeMaterial.html 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>NodeMaterial - 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="Material.html">Material</a> → </p>
  13. <h1 translate="no">NodeMaterial</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Base class for all node materials.</p></div>
  17. </header>
  18. <article>
  19. <div class="container-overview">
  20. <h2>Constructor</h2>
  21. <h3 class="name name-method" id="NodeMaterial" translate="no">new <a href="#NodeMaterial">NodeMaterial</a><span class="signature">()</span> </h3>
  22. <div class="method">
  23. <div class="description">
  24. <p>Constructs a new node material.</p>
  25. </div>
  26. </div>
  27. </div>
  28. <h2 class="subsection-title">Properties</h2>
  29. <div class="member">
  30. <h3 class="name" id="alphaTestNode" translate="no">.<a href="#alphaTestNode">alphaTestNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  31. <div class="description">
  32. <p>The alpha test of node materials is by default inferred from the <code>alphaTest</code>
  33. property. This node property allows to overwrite the default and define the
  34. alpha test with a node instead.</p>
  35. <p>If you don't want to overwrite the alpha test but modify the existing
  36. value instead, use <a href="TSL.html#materialAlphaTest">materialAlphaTest</a>.</p>
  37. <p>Default is <code>null</code>.</p>
  38. </div>
  39. </div>
  40. <div class="member">
  41. <h3 class="name" id="aoNode" translate="no">.<a href="#aoNode">aoNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  42. <div class="description">
  43. <p>The lighting of node materials might be influenced by ambient occlusion.
  44. The default AO is inferred from an ambient occlusion map assigned to <code>aoMap</code>
  45. and the respective <code>aoMapIntensity</code>. This node property allows to overwrite
  46. the default and define the ambient occlusion with a custom node instead.</p>
  47. <p>If you don't want to overwrite the diffuse color but modify the existing
  48. values instead, use <a href="TSL.html#materialAO">materialAO</a>.</p>
  49. <p>Default is <code>null</code>.</p>
  50. </div>
  51. </div>
  52. <div class="member">
  53. <h3 class="name" id="backdropAlphaNode" translate="no">.<a href="#backdropAlphaNode">backdropAlphaNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  54. <div class="description">
  55. <p>This node allows to modulate the influence of <code>backdropNode</code> to the outgoing light.</p>
  56. <p>Default is <code>null</code>.</p>
  57. </div>
  58. </div>
  59. <div class="member">
  60. <h3 class="name" id="backdropNode" translate="no">.<a href="#backdropNode">backdropNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  61. <div class="description">
  62. <p>This node can be used to implement a variety of filter-like effects. The idea is
  63. to store the current rendering into a texture e.g. via <code>viewportSharedTexture()</code>, use it
  64. to create an arbitrary effect and then assign the node composition to this property.
  65. Everything behind the object using this material will now be affected by a filter.</p>
  66. <pre><code class="language-js">const material = new NodeMaterial()
  67. material.transparent = true;
  68. // everything behind the object will be monochromatic
  69. material.backdropNode = saturation( viewportSharedTexture().rgb, 0 );
  70. </code></pre>
  71. <p>Backdrop computations are part of the lighting so only lit materials can use this property.</p>
  72. <p>Default is <code>null</code>.</p>
  73. </div>
  74. </div>
  75. <div class="member">
  76. <h3 class="name" id="castShadowNode" translate="no">.<a href="#castShadowNode">castShadowNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  77. <div class="description">
  78. <p>This node can be used to influence how an object using this node material
  79. casts shadows. To apply a color to shadows, you can simply do:</p>
  80. <pre><code class="language-js">material.castShadowNode = vec4( 1, 0, 0, 1 );
  81. </code></pre>
  82. <p>Which can be nice to fake colored shadows of semi-transparent objects. It
  83. is also common to use the property with <code>Fn</code> function so checks are performed
  84. per fragment.</p>
  85. <pre><code class="language-js">materialCustomShadow.castShadowNode = Fn( () => {
  86. hash( vertexIndex ).greaterThan( 0.5 ).discard();
  87. return materialColor;
  88. } )();
  89. </code></pre>
  90. <p>Default is <code>null</code>.</p>
  91. </div>
  92. </div>
  93. <div class="member">
  94. <h3 class="name" id="castShadowPositionNode" translate="no">.<a href="#castShadowPositionNode">castShadowPositionNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  95. <div class="description">
  96. <p>Allows to overwrite the geometry position used for shadow map projection which
  97. is by default <a href="TSL.html#positionLocal">positionLocal</a>, the vertex position in local space.</p>
  98. <p>Default is <code>null</code>.</p>
  99. </div>
  100. </div>
  101. <div class="member">
  102. <h3 class="name" id="colorNode" translate="no">.<a href="#colorNode">colorNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  103. <div class="description">
  104. <p>The diffuse color of node materials is by default inferred from the
  105. <code>color</code> and <code>map</code> properties. This node property allows to overwrite the default
  106. and define the diffuse color with a node instead.</p>
  107. <pre><code class="language-js">material.colorNode = color( 0xff0000 ); // define red color
  108. </code></pre>
  109. <p>If you don't want to overwrite the diffuse color but modify the existing
  110. values instead, use <a href="TSL.html#materialColor">materialColor</a>.</p>
  111. <pre><code class="language-js">material.colorNode = materialColor.mul( color( 0xff0000 ) ); // give diffuse colors a red tint
  112. </code></pre>
  113. <p>Default is <code>null</code>.</p>
  114. </div>
  115. </div>
  116. <div class="member">
  117. <h3 class="name" id="depthNode" translate="no">.<a href="#depthNode">depthNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  118. <div class="description">
  119. <p>Allows to overwrite depth values in the fragment shader.</p>
  120. <p>Default is <code>null</code>.</p>
  121. </div>
  122. </div>
  123. <div class="member">
  124. <h3 class="name" id="envNode" translate="no">.<a href="#envNode">envNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  125. <div class="description">
  126. <p>The environment of node materials can be defined by an environment
  127. map assigned to the <code>envMap</code> property or by <code>Scene.environment</code>
  128. if the node material is a PBR material. This node property allows to overwrite
  129. the default behavior and define the environment with a custom node.</p>
  130. <pre><code class="language-js">material.envNode = pmremTexture( renderTarget.texture );
  131. </code></pre>
  132. <p>Default is <code>null</code>.</p>
  133. </div>
  134. </div>
  135. <div class="member">
  136. <h3 class="name" id="fog" translate="no">.<a href="#fog">fog</a><span class="type-signature"> : boolean</span> </h3>
  137. <div class="description">
  138. <p>Whether this material is affected by fog or not.</p>
  139. <p>Default is <code>true</code>.</p>
  140. </div>
  141. </div>
  142. <div class="member">
  143. <h3 class="name" id="fragmentNode" translate="no">.<a href="#fragmentNode">fragmentNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  144. <div class="description">
  145. <p>This node property can be used if you need complete freedom in implementing
  146. the fragment shader. Assigning a node will replace the built-in material
  147. logic used in the fragment stage.</p>
  148. <p>Default is <code>null</code>.</p>
  149. </div>
  150. </div>
  151. <div class="member">
  152. <h3 class="name" id="geometryNode" translate="no">.<a href="#geometryNode">geometryNode</a><span class="type-signature"> : function</span> </h3>
  153. <div class="description">
  154. <p>This node property is intended for logic which modifies geometry data once or per animation step.
  155. Apps usually place such logic randomly in initialization routines or in the animation loop.
  156. <code>geometryNode</code> is intended as a dedicated API so there is an intended spot where geometry modifications
  157. can be implemented.</p>
  158. <p>The idea is to assign a <code>Fn</code> definition that holds the geometry modification logic. A typical example
  159. would be a GPU based particle system that provides a node material for usage on app level. The particle
  160. simulation would be implemented as compute shaders and managed inside a <code>Fn</code> function. This function is
  161. eventually assigned to <code>geometryNode</code>.</p>
  162. <p>Default is <code>null</code>.</p>
  163. </div>
  164. </div>
  165. <div class="member">
  166. <h3 class="name" id="hardwareClipping" translate="no">.<a href="#hardwareClipping">hardwareClipping</a><span class="type-signature"> : boolean</span> </h3>
  167. <div class="description">
  168. <p>Whether this material uses hardware clipping or not.
  169. This property is managed by the engine and should not be
  170. modified by apps.</p>
  171. <p>Default is <code>false</code>.</p>
  172. </div>
  173. </div>
  174. <div class="member">
  175. <h3 class="name" id="isNodeMaterial" translate="no">.<a href="#isNodeMaterial">isNodeMaterial</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  176. <div class="description">
  177. <p>This flag can be used for type testing.</p>
  178. <p>Default is <code>true</code>.</p>
  179. </div>
  180. </div>
  181. <div class="member">
  182. <h3 class="name" id="lights" translate="no">.<a href="#lights">lights</a><span class="type-signature"> : boolean</span> </h3>
  183. <div class="description">
  184. <p>Whether this material is affected by lights or not.</p>
  185. <p>Default is <code>false</code>.</p>
  186. </div>
  187. </div>
  188. <div class="member">
  189. <h3 class="name" id="lightsNode" translate="no">.<a href="#lightsNode">lightsNode</a><span class="type-signature"> : <a href="LightsNode.html">LightsNode</a></span> </h3>
  190. <div class="description">
  191. <p>Node materials which set their <code>lights</code> property to <code>true</code>
  192. are affected by all lights of the scene. Sometimes selective
  193. lighting is wanted which means only <em>some</em> lights in the scene
  194. affect a material. This can be achieved by creating an instance
  195. of <a href="LightsNode.html">LightsNode</a> with a list of selective
  196. lights and assign the node to this property.</p>
  197. <pre><code class="language-js">const customLightsNode = lights( [ light1, light2 ] );
  198. material.lightsNode = customLightsNode;
  199. </code></pre>
  200. <p>Default is <code>null</code>.</p>
  201. </div>
  202. </div>
  203. <div class="member">
  204. <h3 class="name" id="maskNode" translate="no">.<a href="#maskNode">maskNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;bool></span> </h3>
  205. <div class="description">
  206. <p>Discards the fragment if the mask value is <code>false</code>.</p>
  207. <p>Default is <code>null</code>.</p>
  208. </div>
  209. </div>
  210. <div class="member">
  211. <h3 class="name" id="mrtNode" translate="no">.<a href="#mrtNode">mrtNode</a><span class="type-signature"> : <a href="MRTNode.html">MRTNode</a></span> </h3>
  212. <div class="description">
  213. <p>MRT configuration is done on renderer or pass level. This node allows to
  214. overwrite what values are written into MRT targets on material level. This
  215. can be useful for implementing selective FX features that should only affect
  216. specific objects.</p>
  217. <p>Default is <code>null</code>.</p>
  218. </div>
  219. </div>
  220. <div class="member">
  221. <h3 class="name" id="normalNode" translate="no">.<a href="#normalNode">normalNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  222. <div class="description">
  223. <p>The normals of node materials are by default inferred from the <code>normalMap</code>/<code>normalScale</code>
  224. or <code>bumpMap</code>/<code>bumpScale</code> properties. This node property allows to overwrite the default
  225. and define the normals with a node instead.</p>
  226. <p>If you don't want to overwrite the normals but modify the existing values instead,
  227. use <a href="TSL.html#materialNormal">materialNormal</a>.</p>
  228. <p>Default is <code>null</code>.</p>
  229. </div>
  230. </div>
  231. <div class="member">
  232. <h3 class="name" id="opacityNode" translate="no">.<a href="#opacityNode">opacityNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  233. <div class="description">
  234. <p>The opacity of node materials is by default inferred from the <code>opacity</code>
  235. and <code>alphaMap</code> properties. This node property allows to overwrite the default
  236. and define the opacity with a node instead.</p>
  237. <p>If you don't want to overwrite the opacity but modify the existing
  238. value instead, use <a href="TSL.html#materialOpacity">materialOpacity</a>.</p>
  239. <p>Default is <code>null</code>.</p>
  240. </div>
  241. </div>
  242. <div class="member">
  243. <h3 class="name" id="outputNode" translate="no">.<a href="#outputNode">outputNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  244. <div class="description">
  245. <p>This node can be used to define the final output of the material.</p>
  246. <p>TODO: Explain the differences to <code>fragmentNode</code>.</p>
  247. <p>Default is <code>null</code>.</p>
  248. </div>
  249. </div>
  250. <div class="member">
  251. <h3 class="name" id="positionNode" translate="no">.<a href="#positionNode">positionNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  252. <div class="description">
  253. <p>The local vertex positions are computed based on multiple factors like the
  254. attribute data, morphing or skinning. This node property allows to overwrite
  255. the default and define local vertex positions with nodes instead.</p>
  256. <p>If you don't want to overwrite the vertex positions but modify the existing
  257. values instead, use <a href="TSL.html#positionLocal">positionLocal</a>.</p>
  258. <pre><code class="language-js">material.positionNode = positionLocal.add( displace );
  259. </code></pre>
  260. <p>Default is <code>null</code>.</p>
  261. </div>
  262. </div>
  263. <div class="member">
  264. <h3 class="name" id="receivedShadowNode" translate="no">.<a href="#receivedShadowNode">receivedShadowNode</a><span class="type-signature"> : function | <a href="FunctionNode.html">FunctionNode</a>.&lt;vec4></span> </h3>
  265. <div class="description">
  266. <p>This node can be used to influence how an object using this node material
  267. receive shadows.</p>
  268. <pre><code class="language-js">const totalShadows = float( 1 ).toVar();
  269. material.receivedShadowNode = Fn( ( [ shadow ] ) => {
  270. totalShadows.mulAssign( shadow );
  271. //return float( 1 ); // bypass received shadows
  272. return shadow.mix( color( 0xff0000 ), 1 ); // modify shadow color
  273. } );</code></pre>
  274. <p>Default is <code>null</code>.</p>
  275. </div>
  276. </div>
  277. <div class="member">
  278. <h3 class="name" id="receivedShadowPositionNode" translate="no">.<a href="#receivedShadowPositionNode">receivedShadowPositionNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  279. <div class="description">
  280. <p>Allows to overwrite the position used for shadow map rendering which
  281. is by default <a href="TSL.html#positionWorld">positionWorld</a>, the vertex position
  282. in world space.</p>
  283. <p>Default is <code>null</code>.</p>
  284. </div>
  285. </div>
  286. <div class="member">
  287. <h3 class="name" id="type" translate="no">.<a href="#type">type</a><span class="type-signature"> : string</span> </h3>
  288. <div class="description">
  289. <p>Represents the type of the node material.</p>
  290. </div>
  291. <dl class="details">
  292. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Material.html#type">Material#type</a></dt>
  293. </dl>
  294. </div>
  295. <div class="member">
  296. <h3 class="name" id="vertexNode" translate="no">.<a href="#vertexNode">vertexNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  297. <div class="description">
  298. <p>This node property can be used if you need complete freedom in implementing
  299. the vertex shader. Assigning a node will replace the built-in material logic
  300. used in the vertex stage.</p>
  301. <p>Default is <code>null</code>.</p>
  302. </div>
  303. </div>
  304. <h2 class="subsection-title">Methods</h2>
  305. <h3 class="name name-method" id="build" translate="no">.<a href="#build">build</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span> </h3>
  306. <div class="method">
  307. <div class="description">
  308. <p>Builds this material with the given node builder.</p>
  309. </div>
  310. <table class="params">
  311. <tbody>
  312. <tr>
  313. <td class="name">
  314. <strong>builder</strong>
  315. </td>
  316. <td class="description last">
  317. <p>The current node builder.</p>
  318. </td>
  319. </tr>
  320. </tbody>
  321. </table>
  322. </div>
  323. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( source : <span class="param-type"><a href="NodeMaterial.html">NodeMaterial</a></span> )</span><span class="type-signature"> : <a href="NodeMaterial.html">NodeMaterial</a></span> </h3>
  324. <div class="method">
  325. <div class="description">
  326. <p>Copies the properties of the given node material to this instance.</p>
  327. </div>
  328. <table class="params">
  329. <tbody>
  330. <tr>
  331. <td class="name">
  332. <strong>source</strong>
  333. </td>
  334. <td class="description last">
  335. <p>The material to copy.</p>
  336. </td>
  337. </tr>
  338. </tbody>
  339. </table>
  340. <dl class="details">
  341. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Material.html#copy">Material#copy</a></dt>
  342. </dl>
  343. <dl class="details">
  344. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node material.</dt>
  345. </dl>
  346. </div>
  347. <h3 class="name name-method" id="customProgramCacheKey" translate="no">.<a href="#customProgramCacheKey">customProgramCacheKey</a><span class="signature">()</span><span class="type-signature"> : string</span> </h3>
  348. <div class="method">
  349. <div class="description">
  350. <p>Allows to define a custom cache key that influence the material key computation
  351. for render objects.</p>
  352. </div>
  353. <dl class="details">
  354. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Material.html#customProgramCacheKey">Material#customProgramCacheKey</a></dt>
  355. </dl>
  356. <dl class="details">
  357. <dt class="tag-returns"><strong>Returns:</strong> The custom cache key.</dt>
  358. </dl>
  359. </div>
  360. <h3 class="name name-method" id="setDefaultValues" translate="no">.<a href="#setDefaultValues">setDefaultValues</a><span class="signature">( material : <span class="param-type"><a href="Material.html">Material</a></span> )</span> </h3>
  361. <div class="method">
  362. <div class="description">
  363. <p>Most classic material types have a node pendant e.g. for <code>MeshBasicMaterial</code>
  364. there is <code>MeshBasicNodeMaterial</code>. This utility method is intended for
  365. defining all material properties of the classic type in the node type.</p>
  366. </div>
  367. <table class="params">
  368. <tbody>
  369. <tr>
  370. <td class="name">
  371. <strong>material</strong>
  372. </td>
  373. <td class="description last">
  374. <p>The material to copy properties with their values to this node material.</p>
  375. </td>
  376. </tr>
  377. </tbody>
  378. </table>
  379. </div>
  380. <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> </h3>
  381. <div class="method">
  382. <div class="description">
  383. <p>Setups the vertex and fragment stage of this node material.</p>
  384. </div>
  385. <table class="params">
  386. <tbody>
  387. <tr>
  388. <td class="name">
  389. <strong>builder</strong>
  390. </td>
  391. <td class="description last">
  392. <p>The current node builder.</p>
  393. </td>
  394. </tr>
  395. </tbody>
  396. </table>
  397. </div>
  398. <h3 class="name name-method" id="setupClipping" translate="no">.<a href="#setupClipping">setupClipping</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="ClippingNode.html">ClippingNode</a></span> </h3>
  399. <div class="method">
  400. <div class="description">
  401. <p>Setups the clipping node.</p>
  402. </div>
  403. <table class="params">
  404. <tbody>
  405. <tr>
  406. <td class="name">
  407. <strong>builder</strong>
  408. </td>
  409. <td class="description last">
  410. <p>The current node builder.</p>
  411. </td>
  412. </tr>
  413. </tbody>
  414. </table>
  415. <dl class="details">
  416. <dt class="tag-returns"><strong>Returns:</strong> The clipping node.</dt>
  417. </dl>
  418. </div>
  419. <h3 class="name name-method" id="setupDepth" translate="no">.<a href="#setupDepth">setupDepth</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span> </h3>
  420. <div class="method">
  421. <div class="description">
  422. <p>Setups the depth of this material.</p>
  423. </div>
  424. <table class="params">
  425. <tbody>
  426. <tr>
  427. <td class="name">
  428. <strong>builder</strong>
  429. </td>
  430. <td class="description last">
  431. <p>The current node builder.</p>
  432. </td>
  433. </tr>
  434. </tbody>
  435. </table>
  436. </div>
  437. <h3 class="name name-method" id="setupDiffuseColor" translate="no">.<a href="#setupDiffuseColor">setupDiffuseColor</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, geometry : <span class="param-type"><a href="BufferGeometry.html">BufferGeometry</a></span> )</span> </h3>
  438. <div class="method">
  439. <div class="description">
  440. <p>Setups the computation of the material's diffuse color.</p>
  441. </div>
  442. <table class="params">
  443. <tbody>
  444. <tr>
  445. <td class="name">
  446. <strong>builder</strong>
  447. </td>
  448. <td class="description last">
  449. <p>The current node builder.</p>
  450. </td>
  451. </tr>
  452. <tr>
  453. <td class="name">
  454. <strong>geometry</strong>
  455. </td>
  456. <td class="description last">
  457. <p>The geometry.</p>
  458. </td>
  459. </tr>
  460. </tbody>
  461. </table>
  462. </div>
  463. <h3 class="name name-method" id="setupEnvironment" translate="no">.<a href="#setupEnvironment">setupEnvironment</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  464. <div class="method">
  465. <div class="description">
  466. <p>Setups the environment node from the material.</p>
  467. </div>
  468. <table class="params">
  469. <tbody>
  470. <tr>
  471. <td class="name">
  472. <strong>builder</strong>
  473. </td>
  474. <td class="description last">
  475. <p>The current node builder.</p>
  476. </td>
  477. </tr>
  478. </tbody>
  479. </table>
  480. <dl class="details">
  481. <dt class="tag-returns"><strong>Returns:</strong> The environment node.</dt>
  482. </dl>
  483. </div>
  484. <h3 class="name name-method" id="setupFog" translate="no">.<a href="#setupFog">setupFog</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, outputNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;vec4></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  485. <div class="method">
  486. <div class="description">
  487. <p>Setup the fog.</p>
  488. </div>
  489. <table class="params">
  490. <tbody>
  491. <tr>
  492. <td class="name">
  493. <strong>builder</strong>
  494. </td>
  495. <td class="description last">
  496. <p>The current node builder.</p>
  497. </td>
  498. </tr>
  499. <tr>
  500. <td class="name">
  501. <strong>outputNode</strong>
  502. </td>
  503. <td class="description last">
  504. <p>The existing output node.</p>
  505. </td>
  506. </tr>
  507. </tbody>
  508. </table>
  509. <dl class="details">
  510. <dt class="tag-returns"><strong>Returns:</strong> The output node.</dt>
  511. </dl>
  512. </div>
  513. <h3 class="name name-method" id="setupHardwareClipping" translate="no">.<a href="#setupHardwareClipping">setupHardwareClipping</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span> </h3>
  514. <div class="method">
  515. <div class="description">
  516. <p>Setups the hardware clipping if available on the current device.</p>
  517. </div>
  518. <table class="params">
  519. <tbody>
  520. <tr>
  521. <td class="name">
  522. <strong>builder</strong>
  523. </td>
  524. <td class="description last">
  525. <p>The current node builder.</p>
  526. </td>
  527. </tr>
  528. </tbody>
  529. </table>
  530. </div>
  531. <h3 class="name name-method" id="setupLightMap" translate="no">.<a href="#setupLightMap">setupLightMap</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  532. <div class="method">
  533. <div class="description">
  534. <p>Setups the light map node from the material.</p>
  535. </div>
  536. <table class="params">
  537. <tbody>
  538. <tr>
  539. <td class="name">
  540. <strong>builder</strong>
  541. </td>
  542. <td class="description last">
  543. <p>The current node builder.</p>
  544. </td>
  545. </tr>
  546. </tbody>
  547. </table>
  548. <dl class="details">
  549. <dt class="tag-returns"><strong>Returns:</strong> The light map node.</dt>
  550. </dl>
  551. </div>
  552. <h3 class="name name-method" id="setupLighting" translate="no">.<a href="#setupLighting">setupLighting</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  553. <div class="method">
  554. <div class="description">
  555. <p>Setups the outgoing light node.</p>
  556. </div>
  557. <table class="params">
  558. <tbody>
  559. <tr>
  560. <td class="name">
  561. <strong>builder</strong>
  562. </td>
  563. <td class="description last">
  564. <p>The current node builder.</p>
  565. </td>
  566. </tr>
  567. </tbody>
  568. </table>
  569. <dl class="details">
  570. <dt class="tag-returns"><strong>Returns:</strong> The outgoing light node.</dt>
  571. </dl>
  572. </div>
  573. <h3 class="name name-method" id="setupLightingModel" translate="no">.<a href="#setupLightingModel">setupLightingModel</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="LightingModel.html">LightingModel</a></span> <span class="type-signature">(abstract) </span></h3>
  574. <div class="method">
  575. <div class="description">
  576. <p>This method should be implemented by most derived materials
  577. since it defines the material's lighting model.</p>
  578. </div>
  579. <table class="params">
  580. <tbody>
  581. <tr>
  582. <td class="name">
  583. <strong>builder</strong>
  584. </td>
  585. <td class="description last">
  586. <p>The current node builder.</p>
  587. </td>
  588. </tr>
  589. </tbody>
  590. </table>
  591. <dl class="details">
  592. <dt class="tag-returns"><strong>Returns:</strong> The lighting model.</dt>
  593. </dl>
  594. </div>
  595. <h3 class="name name-method" id="setupLights" translate="no">.<a href="#setupLights">setupLights</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="LightsNode.html">LightsNode</a></span> </h3>
  596. <div class="method">
  597. <div class="description">
  598. <p>Setups the lights node based on the scene, environment and material.</p>
  599. </div>
  600. <table class="params">
  601. <tbody>
  602. <tr>
  603. <td class="name">
  604. <strong>builder</strong>
  605. </td>
  606. <td class="description last">
  607. <p>The current node builder.</p>
  608. </td>
  609. </tr>
  610. </tbody>
  611. </table>
  612. <dl class="details">
  613. <dt class="tag-returns"><strong>Returns:</strong> The lights node.</dt>
  614. </dl>
  615. </div>
  616. <h3 class="name name-method" id="setupModelViewProjection" translate="no">.<a href="#setupModelViewProjection">setupModelViewProjection</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  617. <div class="method">
  618. <div class="description">
  619. <p>Setups the position in clip space.</p>
  620. </div>
  621. <table class="params">
  622. <tbody>
  623. <tr>
  624. <td class="name">
  625. <strong>builder</strong>
  626. </td>
  627. <td class="description last">
  628. <p>The current node builder.</p>
  629. </td>
  630. </tr>
  631. </tbody>
  632. </table>
  633. <dl class="details">
  634. <dt class="tag-returns"><strong>Returns:</strong> The position in view space.</dt>
  635. </dl>
  636. </div>
  637. <h3 class="name name-method" id="setupNormal" translate="no">.<a href="#setupNormal">setupNormal</a><span class="signature">()</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  638. <div class="method">
  639. <div class="description">
  640. <p>Setups the normal node from the material.</p>
  641. </div>
  642. <dl class="details">
  643. <dt class="tag-returns"><strong>Returns:</strong> The normal node.</dt>
  644. </dl>
  645. </div>
  646. <h3 class="name name-method" id="setupObserver" translate="no">.<a href="#setupObserver">setupObserver</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="NodeMaterialObserver.html">NodeMaterialObserver</a></span> </h3>
  647. <div class="method">
  648. <div class="description">
  649. <p>Setups a node material observer with the given builder.</p>
  650. </div>
  651. <table class="params">
  652. <tbody>
  653. <tr>
  654. <td class="name">
  655. <strong>builder</strong>
  656. </td>
  657. <td class="description last">
  658. <p>The current node builder.</p>
  659. </td>
  660. </tr>
  661. </tbody>
  662. </table>
  663. <dl class="details">
  664. <dt class="tag-returns"><strong>Returns:</strong> The node material observer.</dt>
  665. </dl>
  666. </div>
  667. <h3 class="name name-method" id="setupOutgoingLight" translate="no">.<a href="#setupOutgoingLight">setupOutgoingLight</a><span class="signature">()</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  668. <div class="method">
  669. <div class="description">
  670. <p>Setups the outgoing light node variable</p>
  671. </div>
  672. <dl class="details">
  673. <dt class="tag-returns"><strong>Returns:</strong> The outgoing light node.</dt>
  674. </dl>
  675. </div>
  676. <h3 class="name name-method" id="setupOutput" translate="no">.<a href="#setupOutput">setupOutput</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, outputNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;vec4></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  677. <div class="method">
  678. <div class="description">
  679. <p>Setups the output node.</p>
  680. </div>
  681. <table class="params">
  682. <tbody>
  683. <tr>
  684. <td class="name">
  685. <strong>builder</strong>
  686. </td>
  687. <td class="description last">
  688. <p>The current node builder.</p>
  689. </td>
  690. </tr>
  691. <tr>
  692. <td class="name">
  693. <strong>outputNode</strong>
  694. </td>
  695. <td class="description last">
  696. <p>The existing output node.</p>
  697. </td>
  698. </tr>
  699. </tbody>
  700. </table>
  701. <dl class="details">
  702. <dt class="tag-returns"><strong>Returns:</strong> The output node.</dt>
  703. </dl>
  704. </div>
  705. <h3 class="name name-method" id="setupPosition" translate="no">.<a href="#setupPosition">setupPosition</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  706. <div class="method">
  707. <div class="description">
  708. <p>Setups the computation of the position in local space.</p>
  709. </div>
  710. <table class="params">
  711. <tbody>
  712. <tr>
  713. <td class="name">
  714. <strong>builder</strong>
  715. </td>
  716. <td class="description last">
  717. <p>The current node builder.</p>
  718. </td>
  719. </tr>
  720. </tbody>
  721. </table>
  722. <dl class="details">
  723. <dt class="tag-returns"><strong>Returns:</strong> The position in local space.</dt>
  724. </dl>
  725. </div>
  726. <h3 class="name name-method" id="setupPositionView" translate="no">.<a href="#setupPositionView">setupPositionView</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  727. <div class="method">
  728. <div class="description">
  729. <p>Setups the position node in view space. This method exists
  730. so derived node materials can modify the implementation e.g. sprite materials.</p>
  731. </div>
  732. <table class="params">
  733. <tbody>
  734. <tr>
  735. <td class="name">
  736. <strong>builder</strong>
  737. </td>
  738. <td class="description last">
  739. <p>The current node builder.</p>
  740. </td>
  741. </tr>
  742. </tbody>
  743. </table>
  744. <dl class="details">
  745. <dt class="tag-returns"><strong>Returns:</strong> The position in view space.</dt>
  746. </dl>
  747. </div>
  748. <h3 class="name name-method" id="setupPremultipliedAlpha" translate="no">.<a href="#setupPremultipliedAlpha">setupPremultipliedAlpha</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, outputNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;vec4></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  749. <div class="method">
  750. <div class="description">
  751. <p>Setups premultiplied alpha.</p>
  752. </div>
  753. <table class="params">
  754. <tbody>
  755. <tr>
  756. <td class="name">
  757. <strong>builder</strong>
  758. </td>
  759. <td class="description last">
  760. <p>The current node builder.</p>
  761. </td>
  762. </tr>
  763. <tr>
  764. <td class="name">
  765. <strong>outputNode</strong>
  766. </td>
  767. <td class="description last">
  768. <p>The existing output node.</p>
  769. </td>
  770. </tr>
  771. </tbody>
  772. </table>
  773. <dl class="details">
  774. <dt class="tag-returns"><strong>Returns:</strong> The output node.</dt>
  775. </dl>
  776. </div>
  777. <h3 class="name name-method" id="setupVariants" translate="no">.<a href="#setupVariants">setupVariants</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span> <span class="type-signature">(abstract) </span></h3>
  778. <div class="method">
  779. <div class="description">
  780. <p>Abstract interface method that can be implemented by derived materials
  781. to setup material-specific node variables.</p>
  782. </div>
  783. <table class="params">
  784. <tbody>
  785. <tr>
  786. <td class="name">
  787. <strong>builder</strong>
  788. </td>
  789. <td class="description last">
  790. <p>The current node builder.</p>
  791. </td>
  792. </tr>
  793. </tbody>
  794. </table>
  795. </div>
  796. <h3 class="name name-method" id="setupVertex" translate="no">.<a href="#setupVertex">setupVertex</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  797. <div class="method">
  798. <div class="description">
  799. <p>Setups the logic for the vertex stage.</p>
  800. </div>
  801. <table class="params">
  802. <tbody>
  803. <tr>
  804. <td class="name">
  805. <strong>builder</strong>
  806. </td>
  807. <td class="description last">
  808. <p>The current node builder.</p>
  809. </td>
  810. </tr>
  811. </tbody>
  812. </table>
  813. <dl class="details">
  814. <dt class="tag-returns"><strong>Returns:</strong> The position in clip space.</dt>
  815. </dl>
  816. </div>
  817. <h3 class="name name-method" id="toJSON" translate="no">.<a href="#toJSON">toJSON</a><span class="signature">( meta : <span class="param-type">Object | string</span> )</span><span class="type-signature"> : Object</span> </h3>
  818. <div class="method">
  819. <div class="description">
  820. <p>Serializes this material to JSON.</p>
  821. </div>
  822. <table class="params">
  823. <tbody>
  824. <tr>
  825. <td class="name">
  826. <strong>meta</strong>
  827. </td>
  828. <td class="description last">
  829. <p>The meta information for serialization.</p>
  830. </td>
  831. </tr>
  832. </tbody>
  833. </table>
  834. <dl class="details">
  835. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Material.html#toJSON">Material#toJSON</a></dt>
  836. </dl>
  837. <dl class="details">
  838. <dt class="tag-returns"><strong>Returns:</strong> The serialized node.</dt>
  839. </dl>
  840. </div>
  841. <h2 class="subsection-title">Source</h2>
  842. <p>
  843. <a href="https://github.com/mrdoob/three.js/blob/master/src/materials/nodes/NodeMaterial.js" translate="no" target="_blank" rel="noopener">src/materials/nodes/NodeMaterial.js</a>
  844. </p>
  845. </article>
  846. </section>
  847. <script src="../scripts/linenumber.js"></script>
  848. <script src="../scripts/page.js"></script>
  849. </body>
  850. </html>
粤ICP备19079148号