Skip to content

Commit

Permalink
Nodes: Rename uniforms() to uniformArray(). (#28910)
Browse files Browse the repository at this point in the history
* init branch

* Change class naming to match function
  • Loading branch information
cmhhelgeson authored Jul 26, 2024
1 parent 4cc8fdf commit bfe65cd
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions src/nodes/accessors/ClippingNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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' );
Expand Down Expand Up @@ -101,7 +101,7 @@ class ClippingNode extends Node {

return tslFn( () => {

const clippingPlanes = uniforms( planes );
const clippingPlanes = uniformArray( planes );

let plane;

Expand Down
4 changes: 2 additions & 2 deletions src/nodes/accessors/ReferenceNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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' ) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {

Expand All @@ -32,7 +32,7 @@ class UniformsElementNode extends ArrayElementNode {

}

class UniformsNode extends BufferNode {
class UniformArrayNode extends BufferNode {

constructor( value, elementType = null ) {

Expand Down Expand Up @@ -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 );
8 changes: 4 additions & 4 deletions src/nodes/display/BloomNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 ] ) => {

Expand Down Expand Up @@ -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 ) );

Expand Down
4 changes: 2 additions & 2 deletions src/nodes/display/DenoiseNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/renderers/common/extras/PMREMGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit bfe65cd

Please sign in to comment.