Skip to content

Commit

Permalink
TSL: More consistent names shadowPositionWorld, materialAO (#30152)
Browse files Browse the repository at this point in the history
* Rename `materialAOMap` -> `materialAO`

* Rename `shadowWorldPosition` -> `shadowPositionWorld`

* rename shadowPositionWorld
  • Loading branch information
sunag authored Dec 18, 2024
1 parent fd53a1f commit 74b7a6f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/Three.TSL.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export const mat2 = TSL.mat2;
export const mat3 = TSL.mat3;
export const mat4 = TSL.mat4;
export const matcapUV = TSL.matcapUV;
export const materialAOMap = TSL.materialAOMap;
export const materialAO = TSL.materialAO;
export const materialAlphaTest = TSL.materialAlphaTest;
export const materialAnisotropy = TSL.materialAnisotropy;
export const materialAnisotropyVector = TSL.materialAnisotropyVector;
Expand Down Expand Up @@ -410,7 +410,7 @@ export const select = TSL.select;
export const setCurrentStack = TSL.setCurrentStack;
export const shaderStages = TSL.shaderStages;
export const shadow = TSL.shadow;
export const shadowWorldPosition = TSL.shadowWorldPosition;
export const shadowPositionWorld = TSL.shadowPositionWorld;
export const sharedUniformGroup = TSL.sharedUniformGroup;
export const sheen = TSL.sheen;
export const sheenRoughness = TSL.sheenRoughness;
Expand Down
4 changes: 2 additions & 2 deletions src/materials/nodes/NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NormalBlending } from '../../constants.js';
import { getNodeChildren, getCacheKey } from '../../nodes/core/NodeUtils.js';
import { attribute } from '../../nodes/core/AttributeNode.js';
import { output, diffuseColor, emissive, varyingProperty } from '../../nodes/core/PropertyNode.js';
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap, materialAOMap } from '../../nodes/accessors/MaterialNode.js';
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap, materialAO } from '../../nodes/accessors/MaterialNode.js';
import { modelViewProjection } from '../../nodes/accessors/ModelViewProjectionNode.js';
import { normalLocal } from '../../nodes/accessors/Normal.js';
import { instancedMesh } from '../../nodes/accessors/InstancedMeshNode.js';
Expand Down Expand Up @@ -912,7 +912,7 @@ class NodeMaterial extends Material {

if ( this.aoNode !== null || builder.material.aoMap ) {

const aoNode = this.aoNode !== null ? this.aoNode : materialAOMap;
const aoNode = this.aoNode !== null ? this.aoNode : materialAO;

materialLightsNode.push( new AONode( aoNode ) );

Expand Down
6 changes: 3 additions & 3 deletions src/nodes/accessors/MaterialNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class MaterialNode extends Node {

node = this.getTexture( scope ).rgb.mul( this.getFloat( 'lightMapIntensity' ) );

} else if ( scope === MaterialNode.AO_MAP ) {
} else if ( scope === MaterialNode.AO ) {

node = this.getTexture( scope ).r.sub( 1.0 ).mul( this.getFloat( 'aoMapIntensity' ) ).add( 1.0 );

Expand Down Expand Up @@ -438,7 +438,7 @@ MaterialNode.LINE_DASH_OFFSET = 'dashOffset';
MaterialNode.POINT_WIDTH = 'pointWidth';
MaterialNode.DISPERSION = 'dispersion';
MaterialNode.LIGHT_MAP = 'light';
MaterialNode.AO_MAP = 'ao';
MaterialNode.AO = 'ao';

export default MaterialNode;

Expand Down Expand Up @@ -717,7 +717,7 @@ export const materialLightMap = /*@__PURE__*/ nodeImmutable( MaterialNode, Mater
*
* @type {Node<float>}
*/
export const materialAOMap = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.AO_MAP );
export const materialAO = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.AO );

/**
* TSL object that represents the anisotropy vector of the current material.
Expand Down
6 changes: 3 additions & 3 deletions src/nodes/lighting/ShadowBaseNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ class ShadowBaseNode extends Node {
}

/**
* Setups the shadow position node which is by default the predefined TSL node object `shadowWorldPosition`.
* Setups the shadow position node which is by default the predefined TSL node object `shadowPositionWorld`.
*
* @param {(NodeBuilder|{Material})} object - A configuration object that must at least hold a material reference.
*/
setupShadowPosition( { material } ) {

// Use assign inside an Fn()

shadowWorldPosition.assign( material.shadowPositionNode || positionWorld );
shadowPositionWorld.assign( material.shadowPositionNode || positionWorld );

}

Expand All @@ -88,6 +88,6 @@ class ShadowBaseNode extends Node {
*
* @type {Node<vec3>}
*/
export const shadowWorldPosition = /*@__PURE__*/ vec3().toVar( 'shadowWorldPosition' );
export const shadowPositionWorld = /*@__PURE__*/ vec3().toVar( 'shadowPositionWorld' );

export default ShadowBaseNode;
4 changes: 2 additions & 2 deletions src/nodes/lighting/ShadowNode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ShadowBaseNode, { shadowWorldPosition } from './ShadowBaseNode.js';
import ShadowBaseNode, { shadowPositionWorld } from './ShadowBaseNode.js';
import { float, vec2, vec3, vec4, If, int, Fn, nodeObject } from '../tsl/TSLBase.js';
import { reference } from '../accessors/ReferenceNode.js';
import { texture } from '../accessors/TextureNode.js';
Expand Down Expand Up @@ -548,7 +548,7 @@ class ShadowNode extends ShadowBaseNode {
const shadowIntensity = reference( 'intensity', 'float', shadow ).setGroup( renderGroup );
const normalBias = reference( 'normalBias', 'float', shadow ).setGroup( renderGroup );

const shadowPosition = lightShadowMatrix( light ).mul( shadowWorldPosition.add( transformedNormalWorld.mul( normalBias ) ) );
const shadowPosition = lightShadowMatrix( light ).mul( shadowPositionWorld.add( transformedNormalWorld.mul( normalBias ) ) );
const shadowCoord = this.setupShadowCoord( builder, shadowPosition );

//
Expand Down

0 comments on commit 74b7a6f

Please sign in to comment.