diff --git a/src/nodes/Nodes.js b/src/nodes/Nodes.js index b7439ab67a7bce..2efd80f66de557 100644 --- a/src/nodes/Nodes.js +++ b/src/nodes/Nodes.js @@ -78,7 +78,7 @@ export * from './shadernode/ShaderNode.js'; // accessors export { TBNViewMatrix, parallaxDirection, parallaxUV, transformedBentNormalView } from './accessors/AccessorsUtils.js'; -export { default as UniformsNode, uniforms } from './accessors/UniformsNode.js'; +export { default as UniformArrayNode, uniformArray } from './accessors/UniformArrayNode.js'; export * from './accessors/BitangentNode.js'; export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js'; export { default as BufferNode, buffer } from './accessors/BufferNode.js'; diff --git a/src/nodes/accessors/ClippingNode.js b/src/nodes/accessors/ClippingNode.js index b77ce29fc084d7..5de19a692df46d 100644 --- a/src/nodes/accessors/ClippingNode.js +++ b/src/nodes/accessors/ClippingNode.js @@ -6,7 +6,7 @@ import { diffuseColor, property } from '../core/PropertyNode.js'; import { tslFn } from '../shadernode/ShaderNode.js'; import { loop } from '../utils/LoopNode.js'; import { smoothstep } from '../math/MathNode.js'; -import { uniforms } from './UniformsNode.js'; +import { uniformArray } from './UniformArrayNode.js'; class ClippingNode extends Node { @@ -44,7 +44,7 @@ class ClippingNode extends Node { return tslFn( () => { - const clippingPlanes = uniforms( planes ); + const clippingPlanes = uniformArray( planes ); const distanceToPlane = property( 'float', 'distanceToPlane' ); const distanceGradient = property( 'float', 'distanceToGradient' ); @@ -101,7 +101,7 @@ class ClippingNode extends Node { return tslFn( () => { - const clippingPlanes = uniforms( planes ); + const clippingPlanes = uniformArray( planes ); let plane; diff --git a/src/nodes/accessors/ReferenceNode.js b/src/nodes/accessors/ReferenceNode.js index 5acab12a24907e..fe5e8fb05c72ac 100644 --- a/src/nodes/accessors/ReferenceNode.js +++ b/src/nodes/accessors/ReferenceNode.js @@ -4,7 +4,7 @@ import { uniform } from '../core/UniformNode.js'; import { texture } from './TextureNode.js'; import { buffer } from './BufferNode.js'; import { nodeObject } from '../shadernode/ShaderNode.js'; -import { uniforms } from './UniformsNode.js'; +import { uniformArray } from './UniformArrayNode.js'; import ArrayElementNode from '../utils/ArrayElementNode.js'; class ReferenceElementNode extends ArrayElementNode { @@ -72,7 +72,7 @@ class ReferenceNode extends Node { } else if ( Array.isArray( this.getValueFromReference() ) ) { - node = uniforms( null, uniformType ); + node = uniformArray( null, uniformType ); } else if ( uniformType === 'texture' ) { diff --git a/src/nodes/accessors/UniformsNode.js b/src/nodes/accessors/UniformArrayNode.js similarity index 87% rename from src/nodes/accessors/UniformsNode.js rename to src/nodes/accessors/UniformArrayNode.js index d02539f54243b2..7866c2c25ee725 100644 --- a/src/nodes/accessors/UniformsNode.js +++ b/src/nodes/accessors/UniformArrayNode.js @@ -5,7 +5,7 @@ import { getValueType } from '../core/NodeUtils.js'; import ArrayElementNode from '../utils/ArrayElementNode.js'; import BufferNode from './BufferNode.js'; -class UniformsElementNode extends ArrayElementNode { +class UniformArrayElementNode extends ArrayElementNode { constructor( arrayBuffer, indexNode ) { @@ -32,7 +32,7 @@ class UniformsElementNode extends ArrayElementNode { } -class UniformsNode extends BufferNode { +class UniformArrayNode extends BufferNode { constructor( value, elementType = null ) { @@ -133,14 +133,14 @@ class UniformsNode extends BufferNode { element( indexNode ) { - return nodeObject( new UniformsElementNode( this, nodeObject( indexNode ) ) ); + return nodeObject( new UniformArrayElementNode( this, nodeObject( indexNode ) ) ); } } -export default UniformsNode; +export default UniformArrayNode; -export const uniforms = ( values, nodeType ) => nodeObject( new UniformsNode( values, nodeType ) ); +export const uniformArray = ( values, nodeType ) => nodeObject( new UniformArrayNode( values, nodeType ) ); -addNodeClass( 'UniformsNode', UniformsNode ); +addNodeClass( 'UniformArrayNode', UniformArrayNode ); diff --git a/src/nodes/display/BloomNode.js b/src/nodes/display/BloomNode.js index c806f576fa4664..ed19e9d945d500 100644 --- a/src/nodes/display/BloomNode.js +++ b/src/nodes/display/BloomNode.js @@ -3,7 +3,7 @@ import { addNodeElement, tslFn, nodeObject, float, vec4, int } from '../shaderno import { mix, smoothstep } from '../math/MathNode.js'; import { luminance } from './ColorAdjustmentNode.js'; import { uniform } from '../core/UniformNode.js'; -import { uniforms } from '../accessors/UniformsNode.js'; +import { uniformArray } from '../accessors/UniformArrayNode.js'; import { uv } from '../accessors/UVNode.js'; import { Color } from '../../math/Color.js'; import { passTexture } from './PassNode.js'; @@ -210,8 +210,8 @@ class BloomNode extends TempNode { // composite material - const bloomFactors = uniforms( [ 1.0, 0.8, 0.6, 0.4, 0.2 ] ); - const bloomTintColors = uniforms( [ new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ) ] ); + const bloomFactors = uniformArray( [ 1.0, 0.8, 0.6, 0.4, 0.2 ] ); + const bloomTintColors = uniformArray( [ new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ) ] ); const lerpBloomFactor = tslFn( ( [ factor, radius ] ) => { @@ -283,7 +283,7 @@ class BloomNode extends TempNode { // const colorTexture = texture(); - const gaussianCoefficients = uniforms( coefficients ); + const gaussianCoefficients = uniformArray( coefficients ); const invSize = uniform( new Vector2() ); const direction = uniform( new Vector2( 0.5, 0.5 ) ); diff --git a/src/nodes/display/DenoiseNode.js b/src/nodes/display/DenoiseNode.js index 70ef3f6299e75c..807554a657f94a 100644 --- a/src/nodes/display/DenoiseNode.js +++ b/src/nodes/display/DenoiseNode.js @@ -3,7 +3,7 @@ import { uv } from '../accessors/UVNode.js'; import { addNodeElement, tslFn, nodeObject, float, int, vec2, vec3, vec4, mat2, If } from '../shadernode/ShaderNode.js'; import { NodeUpdateType } from '../core/constants.js'; import { uniform } from '../core/UniformNode.js'; -import { uniforms } from '../accessors/UniformsNode.js'; +import { uniformArray } from '../accessors/UniformArrayNode.js'; import { abs, dot, sin, cos, PI, pow, max } from '../math/MathNode.js'; import { loop } from '../utils/LoopNode.js'; import { luminance } from './ColorAdjustmentNode.js'; @@ -30,7 +30,7 @@ class DenoiseNode extends TempNode { this.index = uniform( 0 ); this._resolution = uniform( new Vector2() ); - this._sampleVectors = uniforms( generatePdSamplePointInitializer( 16, 2, 1 ) ); + this._sampleVectors = uniformArray( generatePdSamplePointInitializer( 16, 2, 1 ) ); this.updateBeforeType = NodeUpdateType.RENDER; diff --git a/src/renderers/common/extras/PMREMGenerator.js b/src/renderers/common/extras/PMREMGenerator.js index 7bae084cca10cc..d57b31fdeff59a 100644 --- a/src/renderers/common/extras/PMREMGenerator.js +++ b/src/renderers/common/extras/PMREMGenerator.js @@ -2,7 +2,7 @@ import NodeMaterial from '../../../nodes/materials/NodeMaterial.js'; import { getDirection, blur } from '../../../nodes/pmrem/PMREMUtils.js'; import { equirectUV } from '../../../nodes/utils/EquirectUVNode.js'; import { uniform } from '../../../nodes/core/UniformNode.js'; -import { uniforms } from '../../../nodes/accessors/UniformsNode.js'; +import { uniformArray } from '../../../nodes/accessors/UniformArrayNode.js'; import { texture } from '../../../nodes/accessors/TextureNode.js'; import { cubeTexture } from '../../../nodes/accessors/CubeTextureNode.js'; import { float, vec3 } from '../../../nodes/shadernode/ShaderNode.js'; @@ -718,7 +718,7 @@ function _getMaterial() { function _getBlurShader( lodMax, width, height ) { - const weights = uniforms( new Array( MAX_SAMPLES ).fill( 0 ) ); + const weights = uniformArray( new Array( MAX_SAMPLES ).fill( 0 ) ); const poleAxis = uniform( new Vector3( 0, 1, 0 ) ); const dTheta = uniform( 0 ); const n = float( MAX_SAMPLES );