NodeBuilder.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. import {
  5. CubeReflectionMapping,
  6. CubeRefractionMapping,
  7. CubeUVReflectionMapping,
  8. CubeUVRefractionMapping,
  9. LinearEncoding,
  10. GammaEncoding
  11. } from '../../../../build/three.module.js';
  12. import { NodeUniform } from './NodeUniform.js';
  13. import { NodeUtils } from './NodeUtils.js';
  14. import { NodeLib } from './NodeLib.js';
  15. import { FunctionNode } from './FunctionNode.js';
  16. import { ConstNode } from './ConstNode.js';
  17. import { StructNode } from './StructNode.js';
  18. import { Vector2Node } from '../inputs/Vector2Node.js';
  19. import { Vector3Node } from '../inputs/Vector3Node.js';
  20. import { Vector4Node } from '../inputs/Vector4Node.js';
  21. import { TextureNode } from '../inputs/TextureNode.js';
  22. import { CubeTextureNode } from '../inputs/CubeTextureNode.js';
  23. import { TextureCubeNode } from '../misc/TextureCubeNode.js';
  24. var elements = NodeUtils.elements,
  25. constructors = [ 'float', 'vec2', 'vec3', 'vec4' ],
  26. convertFormatToType = {
  27. float: 'f',
  28. vec2: 'v2',
  29. vec3: 'v3',
  30. vec4: 'v4',
  31. mat4: 'v4',
  32. int: 'i',
  33. bool: 'b'
  34. },
  35. convertTypeToFormat = {
  36. t: 'sampler2D',
  37. tc: 'samplerCube',
  38. b: 'bool',
  39. i: 'int',
  40. f: 'float',
  41. c: 'vec3',
  42. v2: 'vec2',
  43. v3: 'vec3',
  44. v4: 'vec4',
  45. m3: 'mat3',
  46. m4: 'mat4'
  47. };
  48. function NodeBuilder() {
  49. this.slots = [];
  50. this.caches = [];
  51. this.contexts = [];
  52. this.keywords = {};
  53. this.nodeData = {};
  54. this.requires = {
  55. uv: [],
  56. color: [],
  57. lights: false,
  58. fog: false
  59. };
  60. this.includes = {
  61. consts: [],
  62. functions: [],
  63. structs: []
  64. };
  65. this.attributes = {};
  66. this.prefixCode = [
  67. "#ifdef TEXTURE_LOD_EXT",
  68. " #define texCube(a, b) textureCube(a, b)",
  69. " #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)",
  70. " #define tex2D(a, b) texture2D(a, b)",
  71. " #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)",
  72. "#else",
  73. " #define texCube(a, b) textureCube(a, b)",
  74. " #define texCubeBias(a, b, c) textureCube(a, b, c)",
  75. " #define tex2D(a, b) texture2D(a, b)",
  76. " #define tex2DBias(a, b, c) texture2D(a, b, c)",
  77. "#endif",
  78. "#include <packing>",
  79. "#include <common>"
  80. ].join( "\n" );
  81. this.parsCode = {
  82. vertex: '',
  83. fragment: ''
  84. };
  85. this.code = {
  86. vertex: '',
  87. fragment: ''
  88. };
  89. this.nodeCode = {
  90. vertex: '',
  91. fragment: ''
  92. };
  93. this.resultCode = {
  94. vertex: '',
  95. fragment: ''
  96. };
  97. this.finalCode = {
  98. vertex: '',
  99. fragment: ''
  100. };
  101. this.inputs = {
  102. uniforms: {
  103. list: [],
  104. vertex: [],
  105. fragment: []
  106. },
  107. vars: {
  108. varying: [],
  109. vertex: [],
  110. fragment: []
  111. }
  112. };
  113. // send to material
  114. this.defines = {};
  115. this.uniforms = {};
  116. this.extensions = {};
  117. this.updaters = [];
  118. this.nodes = [];
  119. // --
  120. this.analyzing = false;
  121. }
  122. NodeBuilder.prototype = {
  123. constructor: NodeBuilder,
  124. build: function ( vertex, fragment ) {
  125. this.buildShader( 'vertex', vertex );
  126. this.buildShader( 'fragment', fragment );
  127. if ( this.requires.uv[ 0 ] ) {
  128. this.addVaryCode( 'varying vec2 vUv;' );
  129. this.addVertexFinalCode( 'vUv = uv;' );
  130. }
  131. if ( this.requires.uv[ 1 ] ) {
  132. this.addVaryCode( 'varying vec2 vUv2;' );
  133. this.addVertexParsCode( 'attribute vec2 uv2;' );
  134. this.addVertexFinalCode( 'vUv2 = uv2;' );
  135. }
  136. if ( this.requires.color[ 0 ] ) {
  137. this.addVaryCode( 'varying vec4 vColor;' );
  138. this.addVertexParsCode( 'attribute vec4 color;' );
  139. this.addVertexFinalCode( 'vColor = color;' );
  140. }
  141. if ( this.requires.color[ 1 ] ) {
  142. this.addVaryCode( 'varying vec4 vColor2;' );
  143. this.addVertexParsCode( 'attribute vec4 color2;' );
  144. this.addVertexFinalCode( 'vColor2 = color2;' );
  145. }
  146. if ( this.requires.position ) {
  147. this.addVaryCode( 'varying vec3 vPosition;' );
  148. this.addVertexFinalCode( 'vPosition = transformed;' );
  149. }
  150. if ( this.requires.worldPosition ) {
  151. this.addVaryCode( 'varying vec3 vWPosition;' );
  152. this.addVertexFinalCode( 'vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;' );
  153. }
  154. if ( this.requires.normal ) {
  155. this.addVaryCode( 'varying vec3 vObjectNormal;' );
  156. this.addVertexFinalCode( 'vObjectNormal = normal;' );
  157. }
  158. if ( this.requires.worldNormal ) {
  159. this.addVaryCode( 'varying vec3 vWNormal;' );
  160. this.addVertexFinalCode( 'vWNormal = ( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz;' );
  161. }
  162. return this;
  163. },
  164. buildShader: function ( shader, node ) {
  165. this.resultCode[ shader ] = node.build( this.setShader( shader ), 'v4' );
  166. },
  167. setMaterial: function ( material, renderer ) {
  168. this.material = material;
  169. this.renderer = renderer;
  170. this.requires.lights = material.lights;
  171. this.requires.fog = material.fog;
  172. this.mergeDefines( material.defines );
  173. return this;
  174. },
  175. addFlow: function ( slot, cache, context ) {
  176. return this.addSlot( slot ).addCache( cache ).addContext( context );
  177. },
  178. removeFlow: function () {
  179. return this.removeSlot().removeCache().removeContext();
  180. },
  181. addCache: function ( name ) {
  182. this.cache = name || '';
  183. this.caches.push( this.cache );
  184. return this;
  185. },
  186. removeCache: function () {
  187. this.caches.pop();
  188. this.cache = this.caches[ this.caches.length - 1 ] || '';
  189. return this;
  190. },
  191. addContext: function ( context ) {
  192. this.context = Object.assign( {}, this.context, context );
  193. this.context.extra = this.context.extra || {};
  194. this.contexts.push( this.context );
  195. return this;
  196. },
  197. removeContext: function () {
  198. this.contexts.pop();
  199. this.context = this.contexts[ this.contexts.length - 1 ] || {};
  200. return this;
  201. },
  202. addSlot: function ( name ) {
  203. this.slot = name || '';
  204. this.slots.push( this.slot );
  205. return this;
  206. },
  207. removeSlot: function () {
  208. this.slots.pop();
  209. this.slot = this.slots[ this.slots.length - 1 ] || '';
  210. return this;
  211. },
  212. addVertexCode: function ( code ) {
  213. this.addCode( code, 'vertex' );
  214. },
  215. addFragmentCode: function ( code ) {
  216. this.addCode( code, 'fragment' );
  217. },
  218. addCode: function ( code, shader ) {
  219. this.code[ shader || this.shader ] += code + '\n';
  220. },
  221. addVertexNodeCode: function ( code ) {
  222. this.addNodeCode( code, 'vertex' );
  223. },
  224. addFragmentNodeCode: function ( code ) {
  225. this.addNodeCode( code, 'fragment' );
  226. },
  227. addNodeCode: function ( code, shader ) {
  228. this.nodeCode[ shader || this.shader ] += code + '\n';
  229. },
  230. clearNodeCode: function ( shader ) {
  231. shader = shader || this.shader;
  232. var code = this.nodeCode[ shader ];
  233. this.nodeCode[ shader ] = '';
  234. return code;
  235. },
  236. clearVertexNodeCode: function ( ) {
  237. return this.clearNodeCode( 'vertex' );
  238. },
  239. clearFragmentNodeCode: function ( ) {
  240. return this.clearNodeCode( 'fragment' );
  241. },
  242. addVertexFinalCode: function ( code ) {
  243. this.addFinalCode( code, 'vertex' );
  244. },
  245. addFragmentFinalCode: function ( code ) {
  246. this.addFinalCode( code, 'fragment' );
  247. },
  248. addFinalCode: function ( code, shader ) {
  249. this.finalCode[ shader || this.shader ] += code + '\n';
  250. },
  251. addVertexParsCode: function ( code ) {
  252. this.addParsCode( code, 'vertex' );
  253. },
  254. addFragmentParsCode: function ( code ) {
  255. this.addParsCode( code, 'fragment' );
  256. },
  257. addParsCode: function ( code, shader ) {
  258. this.parsCode[ shader || this.shader ] += code + '\n';
  259. },
  260. addVaryCode: function ( code ) {
  261. this.addVertexParsCode( code );
  262. this.addFragmentParsCode( code );
  263. },
  264. isCache: function ( name ) {
  265. return this.caches.indexOf( name ) !== - 1;
  266. },
  267. isSlot: function ( name ) {
  268. return this.slots.indexOf( name ) !== - 1;
  269. },
  270. define: function ( name, value ) {
  271. this.defines[ name ] = value === undefined ? 1 : value;
  272. },
  273. isDefined: function ( name ) {
  274. return this.defines[ name ] !== undefined;
  275. },
  276. getVar: function ( uuid, type, ns, shader = 'varying', prefix = 'V', label = '' ) {
  277. var vars = this.getVars( shader ),
  278. data = vars[ uuid ];
  279. if ( ! data ) {
  280. var index = vars.length,
  281. name = ns ? ns : 'node' + prefix + index + ( label ? '_' + label : '' );
  282. data = { name: name, type: type };
  283. vars.push( data );
  284. vars[ uuid ] = data;
  285. }
  286. return data;
  287. },
  288. getTempVar: function ( uuid, type, ns, label ) {
  289. return this.getVar( uuid, type, ns, this.shader, 'T', label );
  290. },
  291. getAttribute: function ( name, type ) {
  292. if ( ! this.attributes[ name ] ) {
  293. var varying = this.getVar( name, type );
  294. this.addVertexParsCode( 'attribute ' + type + ' ' + name + ';' );
  295. this.addVertexFinalCode( varying.name + ' = ' + name + ';' );
  296. this.attributes[ name ] = { varying: varying, name: name, type: type };
  297. }
  298. return this.attributes[ name ];
  299. },
  300. getCode: function ( shader ) {
  301. return [
  302. this.prefixCode,
  303. this.parsCode[ shader ],
  304. this.getVarListCode( this.getVars( 'varying' ), 'varying' ),
  305. this.getVarListCode( this.inputs.uniforms[ shader ], 'uniform' ),
  306. this.getIncludesCode( 'consts', shader ),
  307. this.getIncludesCode( 'structs', shader ),
  308. this.getIncludesCode( 'functions', shader ),
  309. 'void main() {',
  310. this.getVarListCode( this.getVars( shader ) ),
  311. this.code[ shader ],
  312. this.resultCode[ shader ],
  313. this.finalCode[ shader ],
  314. '}'
  315. ].join( "\n" );
  316. },
  317. getVarListCode: function ( vars, prefix ) {
  318. prefix = prefix || '';
  319. var code = '';
  320. for ( var i = 0, l = vars.length; i < l; ++ i ) {
  321. var nVar = vars[ i ],
  322. type = nVar.type,
  323. name = nVar.name;
  324. var formatType = this.getFormatByType( type );
  325. if ( formatType === undefined ) {
  326. throw new Error( "Node pars " + formatType + " not found." );
  327. }
  328. code += prefix + ' ' + formatType + ' ' + name + ';\n';
  329. }
  330. return code;
  331. },
  332. getVars: function ( shader ) {
  333. return this.inputs.vars[ shader || this.shader ];
  334. },
  335. getNodeData: function ( node ) {
  336. var uuid = node.isNode ? node.uuid : node;
  337. return this.nodeData[ uuid ] = this.nodeData[ uuid ] || {};
  338. },
  339. createUniform: function ( shader, type, node, ns, needsUpdate, label ) {
  340. var uniforms = this.inputs.uniforms,
  341. index = uniforms.list.length;
  342. var uniform = new NodeUniform( {
  343. type: type,
  344. name: ns ? ns : 'nodeU' + index + ( label ? '_' + label : '' ),
  345. node: node,
  346. needsUpdate: needsUpdate
  347. } );
  348. uniforms.list.push( uniform );
  349. uniforms[ shader ].push( uniform );
  350. uniforms[ shader ][ uniform.name ] = uniform;
  351. this.uniforms[ uniform.name ] = uniform;
  352. return uniform;
  353. },
  354. createVertexUniform: function ( type, node, ns, needsUpdate, label ) {
  355. return this.createUniform( 'vertex', type, node, ns, needsUpdate, label );
  356. },
  357. createFragmentUniform: function ( type, node, ns, needsUpdate, label ) {
  358. return this.createUniform( 'fragment', type, node, ns, needsUpdate, label );
  359. },
  360. include: function ( node, parent, source ) {
  361. var includesStruct;
  362. node = typeof node === 'string' ? NodeLib.get( node ) : node;
  363. if ( this.context.include === false ) {
  364. return node.name;
  365. }
  366. if ( node instanceof FunctionNode ) {
  367. includesStruct = this.includes.functions;
  368. } else if ( node instanceof ConstNode ) {
  369. includesStruct = this.includes.consts;
  370. } else if ( node instanceof StructNode ) {
  371. includesStruct = this.includes.structs;
  372. }
  373. var includes = includesStruct[ this.shader ] = includesStruct[ this.shader ] || [];
  374. if ( node ) {
  375. var included = includes[ node.name ];
  376. if ( ! included ) {
  377. included = includes[ node.name ] = {
  378. node: node,
  379. deps: []
  380. };
  381. includes.push( included );
  382. included.src = node.build( this, 'source' );
  383. }
  384. if ( node instanceof FunctionNode && parent && includes[ parent.name ] && includes[ parent.name ].deps.indexOf( node ) == - 1 ) {
  385. includes[ parent.name ].deps.push( node );
  386. if ( node.includes && node.includes.length ) {
  387. var i = 0;
  388. do {
  389. this.include( node.includes[ i ++ ], parent );
  390. } while ( i < node.includes.length );
  391. }
  392. }
  393. if ( source ) {
  394. included.src = source;
  395. }
  396. return node.name;
  397. } else {
  398. throw new Error( "Include not found." );
  399. }
  400. },
  401. colorToVectorProperties: function ( color ) {
  402. return color.replace( 'r', 'x' ).replace( 'g', 'y' ).replace( 'b', 'z' ).replace( 'a', 'w' );
  403. },
  404. colorToVector: function ( color ) {
  405. return color.replace( /c/g, 'v3' );
  406. },
  407. getIncludes: function ( type, shader ) {
  408. return this.includes[ type ][ shader || this.shader ];
  409. },
  410. getIncludesCode: function () {
  411. function sortByPosition( a, b ) {
  412. return a.deps.length - b.deps.length;
  413. }
  414. return function getIncludesCode( type, shader ) {
  415. var includes = this.getIncludes( type, shader );
  416. if ( ! includes ) return '';
  417. var code = '',
  418. includes = includes.sort( sortByPosition );
  419. for ( var i = 0; i < includes.length; i ++ ) {
  420. if ( includes[ i ].src ) code += includes[ i ].src + '\n';
  421. }
  422. return code;
  423. };
  424. }(),
  425. getConstructorFromLength: function ( len ) {
  426. return constructors[ len - 1 ];
  427. },
  428. isTypeMatrix: function ( format ) {
  429. return /^m/.test( format );
  430. },
  431. getTypeLength: function ( type ) {
  432. if ( type === 'f' ) return 1;
  433. return parseInt( this.colorToVector( type ).substr( 1 ) );
  434. },
  435. getTypeFromLength: function ( len ) {
  436. if ( len === 1 ) return 'f';
  437. return 'v' + len;
  438. },
  439. findNode: function () {
  440. for ( var i = 0; i < arguments.length; i ++ ) {
  441. var nodeCandidate = arguments[ i ];
  442. if ( nodeCandidate !== undefined && nodeCandidate.isNode ) {
  443. return nodeCandidate;
  444. }
  445. }
  446. },
  447. resolve: function () {
  448. for ( var i = 0; i < arguments.length; i ++ ) {
  449. var nodeCandidate = arguments[ i ];
  450. if ( nodeCandidate !== undefined ) {
  451. if ( nodeCandidate.isNode ) {
  452. return nodeCandidate;
  453. } else if ( nodeCandidate.isTexture ) {
  454. switch ( nodeCandidate.mapping ) {
  455. case CubeReflectionMapping:
  456. case CubeRefractionMapping:
  457. return new CubeTextureNode( nodeCandidate );
  458. break;
  459. case CubeUVReflectionMapping:
  460. case CubeUVRefractionMapping:
  461. return new TextureCubeNode( new TextureNode( nodeCandidate ) );
  462. break;
  463. default:
  464. return new TextureNode( nodeCandidate );
  465. }
  466. } else if ( nodeCandidate.isVector2 ) {
  467. return new Vector2Node( nodeCandidate );
  468. } else if ( nodeCandidate.isVector3 ) {
  469. return new Vector3Node( nodeCandidate );
  470. } else if ( nodeCandidate.isVector4 ) {
  471. return new Vector4Node( nodeCandidate );
  472. }
  473. }
  474. }
  475. },
  476. format: function ( code, from, to ) {
  477. var typeToType = this.colorToVector( to + ' <- ' + from );
  478. switch ( typeToType ) {
  479. case 'f <- v2' : return code + '.x';
  480. case 'f <- v3' : return code + '.x';
  481. case 'f <- v4' : return code + '.x';
  482. case 'f <- i' :
  483. case 'f <- b' : return 'float( ' + code + ' )';
  484. case 'v2 <- f' : return 'vec2( ' + code + ' )';
  485. case 'v2 <- v3': return code + '.xy';
  486. case 'v2 <- v4': return code + '.xy';
  487. case 'v2 <- i' :
  488. case 'v2 <- b' : return 'vec2( float( ' + code + ' ) )';
  489. case 'v3 <- f' : return 'vec3( ' + code + ' )';
  490. case 'v3 <- v2': return 'vec3( ' + code + ', 0.0 )';
  491. case 'v3 <- v4': return code + '.xyz';
  492. case 'v3 <- i' :
  493. case 'v3 <- b' : return 'vec2( float( ' + code + ' ) )';
  494. case 'v4 <- f' : return 'vec4( ' + code + ' )';
  495. case 'v4 <- v2': return 'vec4( ' + code + ', 0.0, 1.0 )';
  496. case 'v4 <- v3': return 'vec4( ' + code + ', 1.0 )';
  497. case 'v4 <- i' :
  498. case 'v4 <- b' : return 'vec4( float( ' + code + ' ) )';
  499. case 'i <- f' :
  500. case 'i <- b' : return 'int( ' + code + ' )';
  501. case 'i <- v2' : return 'int( ' + code + '.x )';
  502. case 'i <- v3' : return 'int( ' + code + '.x )';
  503. case 'i <- v4' : return 'int( ' + code + '.x )';
  504. case 'b <- f' : return '( ' + code + ' != 0.0 )';
  505. case 'b <- v2' : return '( ' + code + ' != vec2( 0.0 ) )';
  506. case 'b <- v3' : return '( ' + code + ' != vec3( 0.0 ) )';
  507. case 'b <- v4' : return '( ' + code + ' != vec4( 0.0 ) )';
  508. case 'b <- i' : return '( ' + code + ' != 0 )';
  509. }
  510. return code;
  511. },
  512. getTypeByFormat: function ( format ) {
  513. return convertFormatToType[ format ] || format;
  514. },
  515. getFormatByType: function ( type ) {
  516. return convertTypeToFormat[ type ] || type;
  517. },
  518. getUuid: function ( uuid, useCache ) {
  519. useCache = useCache !== undefined ? useCache : true;
  520. if ( useCache && this.cache ) uuid = this.cache + '-' + uuid;
  521. return uuid;
  522. },
  523. getElementByIndex: function ( index ) {
  524. return elements[ index ];
  525. },
  526. getIndexByElement: function ( elm ) {
  527. return elements.indexOf( elm );
  528. },
  529. isShader: function ( shader ) {
  530. return this.shader === shader;
  531. },
  532. setShader: function ( shader ) {
  533. this.shader = shader;
  534. return this;
  535. },
  536. mergeDefines: function ( defines ) {
  537. for ( var name in defines ) {
  538. this.defines[ name ] = defines[ name ];
  539. }
  540. return this.defines;
  541. },
  542. mergeUniform: function ( uniforms ) {
  543. for ( var name in uniforms ) {
  544. this.uniforms[ name ] = uniforms[ name ];
  545. }
  546. return this.uniforms;
  547. },
  548. getTextureEncodingFromMap: function ( map, gammaOverrideLinear ) {
  549. gammaOverrideLinear = gammaOverrideLinear !== undefined ? gammaOverrideLinear : this.context.gamma && ( this.renderer ? this.renderer.gammaInput : false );
  550. var encoding;
  551. if ( ! map ) {
  552. encoding = LinearEncoding;
  553. } else if ( map.isTexture ) {
  554. encoding = map.encoding;
  555. } else if ( map.isWebGLRenderTarget ) {
  556. console.warn( "THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead." );
  557. encoding = map.texture.encoding;
  558. }
  559. // add backwards compatibility for WebGLRenderer.gammaInput/gammaOutput parameter, should probably be removed at some point.
  560. if ( encoding === LinearEncoding && gammaOverrideLinear ) {
  561. encoding = GammaEncoding;
  562. }
  563. return encoding;
  564. }
  565. };
  566. export { NodeBuilder };