2
0

GLSLNodeBuilder.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. import { MathNode, GLSLNodeParser, NodeBuilder, UniformNode, vectorComponents } from '../../../nodes/Nodes.js';
  2. import NodeUniformBuffer from '../../common/nodes/NodeUniformBuffer.js';
  3. import NodeUniformsGroup from '../../common/nodes/NodeUniformsGroup.js';
  4. import { NodeSampledTexture, NodeSampledCubeTexture, NodeSampledTexture3D } from '../../common/nodes/NodeSampledTexture.js';
  5. import { ByteType, ShortType, RGBAIntegerFormat, RGBIntegerFormat, RedIntegerFormat, RGIntegerFormat, UnsignedByteType, UnsignedIntType, UnsignedShortType, RedFormat, RGFormat, IntType, DataTexture, RGBFormat, RGBAFormat, FloatType } from 'three';
  6. const glslMethods = {
  7. [ MathNode.ATAN2 ]: 'atan',
  8. textureDimensions: 'textureSize',
  9. equals: 'equal'
  10. };
  11. const precisionLib = {
  12. low: 'lowp',
  13. medium: 'mediump',
  14. high: 'highp'
  15. };
  16. const supports = {
  17. swizzleAssign: true,
  18. storageBuffer: false
  19. };
  20. const defaultPrecisions = `
  21. precision highp float;
  22. precision highp int;
  23. precision highp sampler2D;
  24. precision highp sampler3D;
  25. precision highp samplerCube;
  26. precision highp sampler2DArray;
  27. precision highp usampler2D;
  28. precision highp usampler3D;
  29. precision highp usamplerCube;
  30. precision highp usampler2DArray;
  31. precision highp isampler2D;
  32. precision highp isampler3D;
  33. precision highp isamplerCube;
  34. precision highp isampler2DArray;
  35. precision lowp sampler2DShadow;
  36. `;
  37. class GLSLNodeBuilder extends NodeBuilder {
  38. constructor( object, renderer, scene = null ) {
  39. super( object, renderer, new GLSLNodeParser(), scene );
  40. this.uniformGroups = {};
  41. this.transforms = [];
  42. }
  43. getMethod( method ) {
  44. return glslMethods[ method ] || method;
  45. }
  46. getPropertyName( node, shaderStage ) {
  47. return super.getPropertyName( node, shaderStage );
  48. }
  49. getOutputStructName() {
  50. return '';
  51. }
  52. buildFunctionCode( shaderNode ) {
  53. const layout = shaderNode.layout;
  54. const flowData = this.flowShaderNode( shaderNode );
  55. const parameters = [];
  56. for ( const input of layout.inputs ) {
  57. parameters.push( this.getType( input.type ) + ' ' + input.name );
  58. }
  59. //
  60. const code = `${ this.getType( layout.type ) } ${ layout.name }( ${ parameters.join( ', ' ) } ) {
  61. ${ flowData.vars }
  62. ${ flowData.code }
  63. return ${ flowData.result };
  64. }`;
  65. //
  66. return code;
  67. }
  68. setupPBO( storageBufferNode ) {
  69. const attribute = storageBufferNode.value;
  70. if ( attribute.pbo === undefined ) {
  71. const originalArray = attribute.array;
  72. const numElements = attribute.count * attribute.itemSize;
  73. const { itemSize } = attribute;
  74. const isInteger = attribute.array.constructor.name.toLowerCase().includes( 'int' );
  75. let format = isInteger ? RedIntegerFormat : RedFormat;
  76. if ( itemSize === 2 ) {
  77. format = isInteger ? RGIntegerFormat : RGFormat;
  78. } else if ( itemSize === 3 ) {
  79. format = isInteger ? RGBIntegerFormat : RGBFormat;
  80. } else if ( itemSize === 4 ) {
  81. format = isInteger ? RGBAIntegerFormat : RGBAFormat;
  82. }
  83. const typeMap = {
  84. Float32Array: FloatType,
  85. Uint8Array: UnsignedByteType,
  86. Uint16Array: UnsignedShortType,
  87. Uint32Array: UnsignedIntType,
  88. Int8Array: ByteType,
  89. Int16Array: ShortType,
  90. Int32Array: IntType,
  91. Uint8ClampedArray: UnsignedByteType,
  92. };
  93. const width = Math.pow( 2, Math.ceil( Math.log2( Math.sqrt( numElements / itemSize ) ) ) );
  94. let height = Math.ceil( ( numElements / itemSize ) / width );
  95. if ( width * height * itemSize < numElements ) height ++; // Ensure enough space
  96. const newSize = width * height * itemSize;
  97. const newArray = new originalArray.constructor( newSize );
  98. newArray.set( originalArray, 0 );
  99. attribute.array = newArray;
  100. const pboTexture = new DataTexture( attribute.array, width, height, format, typeMap[ attribute.array.constructor.name ] || FloatType );
  101. pboTexture.needsUpdate = true;
  102. pboTexture.isPBOTexture = true;
  103. const pbo = new UniformNode( pboTexture );
  104. pbo.setPrecision( 'high' );
  105. attribute.pboNode = pbo;
  106. attribute.pbo = pbo.value;
  107. this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.label );
  108. }
  109. }
  110. generatePBO( storageArrayElementNode ) {
  111. const { node, indexNode } = storageArrayElementNode;
  112. const attribute = node.value;
  113. if ( this.renderer.backend.has( attribute ) ) {
  114. const attributeData = this.renderer.backend.get( attribute );
  115. attributeData.pbo = attribute.pbo;
  116. }
  117. const nodeUniform = this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.label );
  118. const textureName = this.getPropertyName( nodeUniform );
  119. indexNode.increaseUsage( this ); // force cache generate to be used as index in x,y
  120. const indexSnippet = indexNode.build( this, 'uint' );
  121. const elementNodeData = this.getDataFromNode( storageArrayElementNode );
  122. let propertyName = elementNodeData.propertyName;
  123. if ( propertyName === undefined ) {
  124. // property element
  125. const nodeVar = this.getVarFromNode( storageArrayElementNode );
  126. propertyName = this.getPropertyName( nodeVar );
  127. // property size
  128. const bufferNodeData = this.getDataFromNode( node );
  129. let propertySizeName = bufferNodeData.propertySizeName;
  130. if ( propertySizeName === undefined ) {
  131. propertySizeName = propertyName + 'Size';
  132. this.getVarFromNode( node, propertySizeName, 'uint' );
  133. this.addLineFlowCode( `${ propertySizeName } = uint( textureSize( ${ textureName }, 0 ).x )` );
  134. bufferNodeData.propertySizeName = propertySizeName;
  135. }
  136. //
  137. const { itemSize } = attribute;
  138. const channel = '.' + vectorComponents.join( '' ).slice( 0, itemSize );
  139. const uvSnippet = `ivec2(${indexSnippet} % ${ propertySizeName }, ${indexSnippet} / ${ propertySizeName })`;
  140. const snippet = this.generateTextureLoad( null, textureName, uvSnippet, null, '0' );
  141. //
  142. const typePrefix = attribute.array.constructor.name.toLowerCase().charAt( 0 );
  143. let prefix = 'vec4';
  144. if ( typePrefix === 'u' ) {
  145. prefix = 'uvec4';
  146. } else if ( typePrefix === 'i' ) {
  147. prefix = 'ivec4';
  148. }
  149. this.addLineFlowCode( `${ propertyName } = ${prefix}(${ snippet })${channel}` );
  150. elementNodeData.propertyName = propertyName;
  151. }
  152. return propertyName;
  153. }
  154. generateTextureLoad( texture, textureProperty, uvIndexSnippet, depthSnippet, levelSnippet = '0' ) {
  155. if ( depthSnippet ) {
  156. return `texelFetch( ${ textureProperty }, ivec3( ${ uvIndexSnippet }, ${ depthSnippet } ), ${ levelSnippet } )`;
  157. } else {
  158. return `texelFetch( ${ textureProperty }, ${ uvIndexSnippet }, ${ levelSnippet } )`;
  159. }
  160. }
  161. generateTexture( texture, textureProperty, uvSnippet, depthSnippet ) {
  162. if ( texture.isDepthTexture ) {
  163. return `texture( ${ textureProperty }, ${ uvSnippet } ).x`;
  164. } else {
  165. if ( depthSnippet ) uvSnippet = `vec3( ${ uvSnippet }, ${ depthSnippet } )`;
  166. return `texture( ${ textureProperty }, ${ uvSnippet } )`;
  167. }
  168. }
  169. generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet ) {
  170. return `textureLod( ${ textureProperty }, ${ uvSnippet }, ${ levelSnippet } )`;
  171. }
  172. generateTextureGrad( texture, textureProperty, uvSnippet, gradSnippet ) {
  173. return `textureGrad( ${ textureProperty }, ${ uvSnippet }, ${ gradSnippet[ 0 ] }, ${ gradSnippet[ 1 ] } )`;
  174. }
  175. generateTextureCompare( texture, textureProperty, uvSnippet, compareSnippet, depthSnippet, shaderStage = this.shaderStage ) {
  176. if ( shaderStage === 'fragment' ) {
  177. return `texture( ${ textureProperty }, vec3( ${ uvSnippet }, ${ compareSnippet } ) )`;
  178. } else {
  179. console.error( `WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${ shaderStage } shader.` );
  180. }
  181. }
  182. getVars( shaderStage ) {
  183. const snippets = [];
  184. const vars = this.vars[ shaderStage ];
  185. if ( vars !== undefined ) {
  186. for ( const variable of vars ) {
  187. snippets.push( `${ this.getVar( variable.type, variable.name ) };` );
  188. }
  189. }
  190. return snippets.join( '\n\t' );
  191. }
  192. getUniforms( shaderStage ) {
  193. const uniforms = this.uniforms[ shaderStage ];
  194. const bindingSnippets = [];
  195. const uniformGroups = {};
  196. for ( const uniform of uniforms ) {
  197. let snippet = null;
  198. let group = false;
  199. if ( uniform.type === 'texture' ) {
  200. const texture = uniform.node.value;
  201. let typePrefix = '';
  202. if ( texture.isPBOTexture === true ) {
  203. const prefix = texture.source.data.data.constructor.name.toLowerCase().charAt( 0 );
  204. if ( prefix === 'u' || prefix === 'i' ) {
  205. typePrefix = prefix;
  206. }
  207. }
  208. if ( texture.compareFunction ) {
  209. snippet = `sampler2DShadow ${ uniform.name };`;
  210. } else if ( texture.isDataArrayTexture === true ) {
  211. snippet = `${typePrefix}sampler2DArray ${ uniform.name };`;
  212. } else {
  213. snippet = `${typePrefix}sampler2D ${ uniform.name };`;
  214. }
  215. } else if ( uniform.type === 'cubeTexture' ) {
  216. snippet = `samplerCube ${ uniform.name };`;
  217. } else if ( uniform.type === 'texture3D' ) {
  218. snippet = `sampler3D ${ uniform.name };`;
  219. } else if ( uniform.type === 'buffer' ) {
  220. const bufferNode = uniform.node;
  221. const bufferType = this.getType( bufferNode.bufferType );
  222. const bufferCount = bufferNode.bufferCount;
  223. const bufferCountSnippet = bufferCount > 0 ? bufferCount : '';
  224. snippet = `${bufferNode.name} {\n\t${ bufferType } ${ uniform.name }[${ bufferCountSnippet }];\n};\n`;
  225. } else {
  226. const vectorType = this.getVectorType( uniform.type );
  227. snippet = `${vectorType} ${uniform.name};`;
  228. group = true;
  229. }
  230. const precision = uniform.node.precision;
  231. if ( precision !== null ) {
  232. snippet = precisionLib[ precision ] + ' ' + snippet;
  233. }
  234. if ( group ) {
  235. snippet = '\t' + snippet;
  236. const groupName = uniform.groupNode.name;
  237. const groupSnippets = uniformGroups[ groupName ] || ( uniformGroups[ groupName ] = [] );
  238. groupSnippets.push( snippet );
  239. } else {
  240. snippet = 'uniform ' + snippet;
  241. bindingSnippets.push( snippet );
  242. }
  243. }
  244. let output = '';
  245. for ( const name in uniformGroups ) {
  246. const groupSnippets = uniformGroups[ name ];
  247. output += this._getGLSLUniformStruct( shaderStage + '_' + name, groupSnippets.join( '\n' ) ) + '\n';
  248. }
  249. output += bindingSnippets.join( '\n' );
  250. return output;
  251. }
  252. getTypeFromAttribute( attribute ) {
  253. let nodeType = super.getTypeFromAttribute( attribute );
  254. if ( /^[iu]/.test( nodeType ) && attribute.gpuType !== IntType ) {
  255. let dataAttribute = attribute;
  256. if ( attribute.isInterleavedBufferAttribute ) dataAttribute = attribute.data;
  257. const array = dataAttribute.array;
  258. if ( ( array instanceof Uint32Array || array instanceof Int32Array || array instanceof Uint16Array || array instanceof Int16Array ) === false ) {
  259. nodeType = nodeType.slice( 1 );
  260. }
  261. }
  262. return nodeType;
  263. }
  264. getAttributes( shaderStage ) {
  265. let snippet = '';
  266. if ( shaderStage === 'vertex' || shaderStage === 'compute' ) {
  267. const attributes = this.getAttributesArray();
  268. let location = 0;
  269. for ( const attribute of attributes ) {
  270. snippet += `layout( location = ${ location ++ } ) in ${ attribute.type } ${ attribute.name };\n`;
  271. }
  272. }
  273. return snippet;
  274. }
  275. getStructMembers( struct ) {
  276. const snippets = [];
  277. const members = struct.getMemberTypes();
  278. for ( let i = 0; i < members.length; i ++ ) {
  279. const member = members[ i ];
  280. snippets.push( `layout( location = ${i} ) out ${ member} m${i};` );
  281. }
  282. return snippets.join( '\n' );
  283. }
  284. getStructs( shaderStage ) {
  285. const snippets = [];
  286. const structs = this.structs[ shaderStage ];
  287. if ( structs.length === 0 ) {
  288. return 'layout( location = 0 ) out vec4 fragColor;\n';
  289. }
  290. for ( let index = 0, length = structs.length; index < length; index ++ ) {
  291. const struct = structs[ index ];
  292. let snippet = '\n';
  293. snippet += this.getStructMembers( struct );
  294. snippet += '\n';
  295. snippets.push( snippet );
  296. }
  297. return snippets.join( '\n\n' );
  298. }
  299. getVaryings( shaderStage ) {
  300. let snippet = '';
  301. const varyings = this.varyings;
  302. if ( shaderStage === 'vertex' || shaderStage === 'compute' ) {
  303. for ( const varying of varyings ) {
  304. if ( shaderStage === 'compute' ) varying.needsInterpolation = true;
  305. const type = varying.type;
  306. const flat = type.includes( 'int' ) || type.includes( 'uv' ) || type.includes( 'iv' ) ? 'flat ' : '';
  307. snippet += `${flat}${varying.needsInterpolation ? 'out' : '/*out*/'} ${type} ${varying.name};\n`;
  308. }
  309. } else if ( shaderStage === 'fragment' ) {
  310. for ( const varying of varyings ) {
  311. if ( varying.needsInterpolation ) {
  312. const type = varying.type;
  313. const flat = type.includes( 'int' ) || type.includes( 'uv' ) || type.includes( 'iv' ) ? 'flat ' : '';
  314. snippet += `${flat}in ${type} ${varying.name};\n`;
  315. }
  316. }
  317. }
  318. return snippet;
  319. }
  320. getVertexIndex() {
  321. return 'uint( gl_VertexID )';
  322. }
  323. getInstanceIndex() {
  324. return 'uint( gl_InstanceID )';
  325. }
  326. getFrontFacing() {
  327. return 'gl_FrontFacing';
  328. }
  329. getFragCoord() {
  330. return 'gl_FragCoord';
  331. }
  332. getFragDepth() {
  333. return 'gl_FragDepth';
  334. }
  335. isAvailable( name ) {
  336. let result = supports[ name ];
  337. if ( result === undefined ) {
  338. if ( name === 'float32Filterable' ) {
  339. const extentions = this.renderer.backend.extensions;
  340. if ( extentions.has( 'OES_texture_float_linear' ) ) {
  341. extentions.get( 'OES_texture_float_linear' );
  342. result = true;
  343. } else {
  344. result = false;
  345. }
  346. }
  347. supports[ name ] = result;
  348. }
  349. return result;
  350. }
  351. isFlipY() {
  352. return true;
  353. }
  354. registerTransform( varyingName, attributeNode ) {
  355. this.transforms.push( { varyingName, attributeNode } );
  356. }
  357. getTransforms( /* shaderStage */ ) {
  358. const transforms = this.transforms;
  359. let snippet = '';
  360. for ( let i = 0; i < transforms.length; i ++ ) {
  361. const transform = transforms[ i ];
  362. const attributeName = this.getPropertyName( transform.attributeNode );
  363. snippet += `${ transform.varyingName } = ${ attributeName };\n\t`;
  364. }
  365. return snippet;
  366. }
  367. _getGLSLUniformStruct( name, vars ) {
  368. return `
  369. layout( std140 ) uniform ${name} {
  370. ${vars}
  371. };`;
  372. }
  373. _getGLSLVertexCode( shaderData ) {
  374. return `#version 300 es
  375. ${ this.getSignature() }
  376. // precision
  377. ${ defaultPrecisions }
  378. // uniforms
  379. ${shaderData.uniforms}
  380. // varyings
  381. ${shaderData.varyings}
  382. // attributes
  383. ${shaderData.attributes}
  384. // codes
  385. ${shaderData.codes}
  386. void main() {
  387. // vars
  388. ${shaderData.vars}
  389. // transforms
  390. ${shaderData.transforms}
  391. // flow
  392. ${shaderData.flow}
  393. gl_PointSize = 1.0;
  394. }
  395. `;
  396. }
  397. _getGLSLFragmentCode( shaderData ) {
  398. return `#version 300 es
  399. ${ this.getSignature() }
  400. // precision
  401. ${ defaultPrecisions }
  402. // uniforms
  403. ${shaderData.uniforms}
  404. // varyings
  405. ${shaderData.varyings}
  406. // codes
  407. ${shaderData.codes}
  408. ${shaderData.structs}
  409. void main() {
  410. // vars
  411. ${shaderData.vars}
  412. // flow
  413. ${shaderData.flow}
  414. }
  415. `;
  416. }
  417. buildCode() {
  418. const shadersData = this.material !== null ? { fragment: {}, vertex: {} } : { compute: {} };
  419. for ( const shaderStage in shadersData ) {
  420. let flow = '// code\n\n';
  421. flow += this.flowCode[ shaderStage ];
  422. const flowNodes = this.flowNodes[ shaderStage ];
  423. const mainNode = flowNodes[ flowNodes.length - 1 ];
  424. for ( const node of flowNodes ) {
  425. const flowSlotData = this.getFlowData( node/*, shaderStage*/ );
  426. const slotName = node.name;
  427. if ( slotName ) {
  428. if ( flow.length > 0 ) flow += '\n';
  429. flow += `\t// flow -> ${ slotName }\n\t`;
  430. }
  431. flow += `${ flowSlotData.code }\n\t`;
  432. if ( node === mainNode && shaderStage !== 'compute' ) {
  433. flow += '// result\n\t';
  434. if ( shaderStage === 'vertex' ) {
  435. flow += 'gl_Position = ';
  436. flow += `${ flowSlotData.result };`;
  437. } else if ( shaderStage === 'fragment' ) {
  438. if ( ! node.outputNode.isOutputStructNode ) {
  439. flow += 'fragColor = ';
  440. flow += `${ flowSlotData.result };`;
  441. }
  442. }
  443. }
  444. }
  445. const stageData = shadersData[ shaderStage ];
  446. stageData.uniforms = this.getUniforms( shaderStage );
  447. stageData.attributes = this.getAttributes( shaderStage );
  448. stageData.varyings = this.getVaryings( shaderStage );
  449. stageData.vars = this.getVars( shaderStage );
  450. stageData.structs = this.getStructs( shaderStage );
  451. stageData.codes = this.getCodes( shaderStage );
  452. stageData.transforms = this.getTransforms( shaderStage );
  453. stageData.flow = flow;
  454. }
  455. if ( this.material !== null ) {
  456. this.vertexShader = this._getGLSLVertexCode( shadersData.vertex );
  457. this.fragmentShader = this._getGLSLFragmentCode( shadersData.fragment );
  458. } else {
  459. this.computeShader = this._getGLSLVertexCode( shadersData.compute );
  460. }
  461. }
  462. getUniformFromNode( node, type, shaderStage, name = null ) {
  463. const uniformNode = super.getUniformFromNode( node, type, shaderStage, name );
  464. const nodeData = this.getDataFromNode( node, shaderStage, this.globalCache );
  465. let uniformGPU = nodeData.uniformGPU;
  466. if ( uniformGPU === undefined ) {
  467. if ( type === 'texture' ) {
  468. uniformGPU = new NodeSampledTexture( uniformNode.name, uniformNode.node );
  469. this.bindings[ shaderStage ].push( uniformGPU );
  470. } else if ( type === 'cubeTexture' ) {
  471. uniformGPU = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node );
  472. this.bindings[ shaderStage ].push( uniformGPU );
  473. } else if ( type === 'texture3D' ) {
  474. uniformGPU = new NodeSampledTexture3D( uniformNode.name, uniformNode.node );
  475. this.bindings[ shaderStage ].push( uniformGPU );
  476. } else if ( type === 'buffer' ) {
  477. node.name = `NodeBuffer_${ node.id }`;
  478. uniformNode.name = `buffer${ node.id }`;
  479. const buffer = new NodeUniformBuffer( node );
  480. buffer.name = node.name;
  481. this.bindings[ shaderStage ].push( buffer );
  482. uniformGPU = buffer;
  483. } else {
  484. const group = node.groupNode;
  485. const groupName = group.name;
  486. const uniformsStage = this.uniformGroups[ shaderStage ] || ( this.uniformGroups[ shaderStage ] = {} );
  487. let uniformsGroup = uniformsStage[ groupName ];
  488. if ( uniformsGroup === undefined ) {
  489. uniformsGroup = new NodeUniformsGroup( shaderStage + '_' + groupName, group );
  490. //uniformsGroup.setVisibility( gpuShaderStageLib[ shaderStage ] );
  491. uniformsStage[ groupName ] = uniformsGroup;
  492. this.bindings[ shaderStage ].push( uniformsGroup );
  493. }
  494. uniformGPU = this.getNodeUniform( uniformNode, type );
  495. uniformsGroup.addUniform( uniformGPU );
  496. }
  497. nodeData.uniformGPU = uniformGPU;
  498. }
  499. return uniformNode;
  500. }
  501. }
  502. export default GLSLNodeBuilder;