GLSLNodeBuilder.js 18 KB

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