Bladeren bron

Nodes: Merge *MaterialNode into singular MaterialNode, fix exports, some cleanup (#26976)

* Nodes: Merge *MaterialNode into singular MaterialNode, fix exports, some cleanup

Signed-off-by: Levi Pesin <[email protected]>

* Fix

Signed-off-by: Levi Pesin <[email protected]>

* Revert

---------

Signed-off-by: Levi Pesin <[email protected]>
Levi Pesin 1 jaar geleden
bovenliggende
commit
31872ee5c7

+ 1 - 4
examples/jsm/nodes/Nodes.js

@@ -71,11 +71,8 @@ export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute
 export { default as BufferNode, buffer } from './accessors/BufferNode.js';
 export { default as CameraNode, cameraProjectionMatrix, cameraViewMatrix, cameraNormalMatrix, cameraWorldMatrix, cameraPosition, cameraNear, cameraFar } from './accessors/CameraNode.js';
 export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
-export { default as ExtendedMaterialNode, materialNormal } from './accessors/ExtendedMaterialNode.js';
-export { default as FatPointsMaterialNode, materialPointWidth } from './accessors/FatPointsMaterialNode.js';
 export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
-export { default as LineMaterialNode, materialLineDashSize, materialLineDashOffset, materialLineGapSize, materialLineScale, materialLineWidth } from './accessors/LineMaterialNode.js';
-export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialReflectivity, materialRoughness, materialMetalness, materialRotation, materialSheen, materialSheenRoughness } from './accessors/MaterialNode.js';
+export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth } from './accessors/MaterialNode.js';
 export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
 export { default as MorphNode, morph } from './accessors/MorphNode.js';
 export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';

+ 0 - 75
examples/jsm/nodes/accessors/ExtendedMaterialNode.js

@@ -1,75 +0,0 @@
-import MaterialNode from './MaterialNode.js';
-import { materialReference } from './MaterialReferenceNode.js';
-import { normalView } from './NormalNode.js';
-import { normalMap } from '../display/NormalMapNode.js';
-import { bumpMap } from '../display/BumpMapNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeImmutable } from '../shadernode/ShaderNode.js';
-
-class ExtendedMaterialNode extends MaterialNode {
-
-	constructor( scope ) {
-
-		super( scope );
-
-	}
-
-	getNodeType( builder ) {
-
-		const scope = this.scope;
-		let type = null;
-
-		if ( scope === ExtendedMaterialNode.NORMAL || scope === ExtendedMaterialNode.CLEARCOAT_NORMAL ) {
-
-			type = 'vec3';
-
-		}
-
-		return type || super.getNodeType( builder );
-
-	}
-
-	setup( builder ) {
-
-		const material = builder.material;
-		const scope = this.scope;
-
-		let node = null;
-
-		if ( scope === ExtendedMaterialNode.NORMAL ) {
-
-			if ( material.normalMap ) {
-
-				node = normalMap( this.getTexture( 'normalMap' ), materialReference( 'normalScale', 'vec2' ) );
-
-			} else if ( material.bumpMap ) {
-
-				node = bumpMap( this.getTexture( 'bumpMap' ).r, materialReference( 'bumpScale', 'float' ) );
-
-			} else {
-
-				node = normalView;
-
-			}
-
-		} else if ( scope === ExtendedMaterialNode.CLEARCOAT_NORMAL ) {
-
-			node = material.clearcoatNormalMap ? normalMap( this.getTexture( 'clearcoatNormalMap' ), materialReference( 'clearcoatNormalScale', 'vec2' ) ) : normalView;
-
-		}
-
-		return node || super.setup( builder );
-
-	}
-
-}
-
-ExtendedMaterialNode.NORMAL = 'normal';
-ExtendedMaterialNode.CLEARCOAT_NORMAL = 'clearcoatNormal';
-
-export default ExtendedMaterialNode;
-
-export const materialNormal = nodeImmutable( ExtendedMaterialNode, ExtendedMaterialNode.NORMAL );
-export const materialClearcoatNormal = nodeImmutable( ExtendedMaterialNode, ExtendedMaterialNode.CLEARCOAT_NORMAL );
-
-addNodeClass( 'ExtendedMaterialNode', ExtendedMaterialNode );

+ 0 - 21
examples/jsm/nodes/accessors/FatPointsMaterialNode.js

@@ -1,21 +0,0 @@
-import MaterialNode from './MaterialNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeImmutable } from '../shadernode/ShaderNode.js';
-
-class FatPointsMaterialNode extends MaterialNode {
-
-	setup( /*builder*/ ) {
-
-		return this.getFloat( this.scope );
-
-	}
-
-}
-
-FatPointsMaterialNode.POINTWIDTH = 'pointWidth';
-
-export default FatPointsMaterialNode;
-
-export const materialPointWidth = nodeImmutable( FatPointsMaterialNode, FatPointsMaterialNode.POINTWIDTH );
-
-addNodeClass( 'FatPointsMaterialNode', FatPointsMaterialNode );

+ 0 - 29
examples/jsm/nodes/accessors/LineMaterialNode.js

@@ -1,29 +0,0 @@
-import MaterialNode from './MaterialNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeImmutable } from '../shadernode/ShaderNode.js';
-
-class LineMaterialNode extends MaterialNode {
-
-	setup( /*builder*/ ) {
-
-		return this.getFloat( this.scope );
-
-	}
-
-}
-
-LineMaterialNode.SCALE = 'scale';
-LineMaterialNode.DASH_SIZE = 'dashSize';
-LineMaterialNode.GAP_SIZE = 'gapSize';
-LineMaterialNode.LINEWIDTH = 'linewidth';
-LineMaterialNode.DASH_OFFSET = 'dashOffset';
-
-export default LineMaterialNode;
-
-export const materialLineScale = nodeImmutable( LineMaterialNode, LineMaterialNode.SCALE );
-export const materialLineDashOffset = nodeImmutable( LineMaterialNode, LineMaterialNode.DASH_OFFSET );
-export const materialLineDashSize = nodeImmutable( LineMaterialNode, LineMaterialNode.DASH_SIZE );
-export const materialLineGapSize = nodeImmutable( LineMaterialNode, LineMaterialNode.GAP_SIZE );
-export const materialLineWidth = nodeImmutable( LineMaterialNode, LineMaterialNode.LINEWIDTH );
-
-addNodeClass( 'LineMaterialNode', LineMaterialNode );

+ 68 - 31
examples/jsm/nodes/accessors/MaterialNode.js

@@ -1,6 +1,7 @@
 import Node, { addNodeClass } from '../core/Node.js';
 import { reference } from './ReferenceNode.js';
 import { materialReference } from './MaterialReferenceNode.js';
+import { normalView } from './NormalNode.js';
 import { nodeImmutable, float } from '../shadernode/ShaderNode.js';
 
 const _propertyCache = new Map();
@@ -45,7 +46,7 @@ class MaterialNode extends Node {
 
 	getTexture( property ) {
 
-		return this.getCache( property, 'texture' );
+		return this.getCache( property === 'map' ? 'map' : property + 'Map', 'texture' );
 
 	}
 
@@ -56,17 +57,9 @@ class MaterialNode extends Node {
 
 		let node = null;
 
-		if ( scope === MaterialNode.ALPHA_TEST || scope === MaterialNode.SHININESS || scope === MaterialNode.REFLECTIVITY || scope === MaterialNode.ROTATION || scope === MaterialNode.IRIDESCENCE || scope === MaterialNode.IRIDESCENCE_IOR ) {
+		if ( scope === MaterialNode.COLOR ) {
 
-			node = this.getFloat( scope );
-
-		} else if ( scope === MaterialNode.SPECULAR_COLOR ) {
-
-			node = this.getColor( 'specular' );
-
-		} else if ( scope === MaterialNode.COLOR ) {
-
-			const colorNode = this.getColor( 'color' );
+			const colorNode = this.getColor( scope );
 
 			if ( material.map && material.map.isTexture === true ) {
 
@@ -80,11 +73,11 @@ class MaterialNode extends Node {
 
 		} else if ( scope === MaterialNode.OPACITY ) {
 
-			const opacityNode = this.getFloat( 'opacity' );
+			const opacityNode = this.getFloat( scope );
 
 			if ( material.alphaMap && material.alphaMap.isTexture === true ) {
 
-				node = opacityNode.mul( this.getTexture( 'alphaMap' ) );
+				node = opacityNode.mul( this.getTexture( 'alpha' ) );
 
 			} else {
 
@@ -96,7 +89,7 @@ class MaterialNode extends Node {
 
 			if ( material.specularMap && material.specularMap.isTexture === true ) {
 
-				node = this.getTexture( 'specularMap' ).r;
+				node = this.getTexture( scope ).r;
 
 			} else {
 
@@ -104,13 +97,13 @@ class MaterialNode extends Node {
 
 			}
 
-		} else if ( scope === MaterialNode.ROUGHNESS ) {
+		} else if ( scope === MaterialNode.ROUGHNESS ) { // TODO: cleanup similar branches
 
-			const roughnessNode = this.getFloat( 'roughness' );
+			const roughnessNode = this.getFloat( scope );
 
 			if ( material.roughnessMap && material.roughnessMap.isTexture === true ) {
 
-				node = roughnessNode.mul( this.getTexture( 'roughnessMap' ).g );
+				node = roughnessNode.mul( this.getTexture( scope ).g );
 
 			} else {
 
@@ -120,11 +113,11 @@ class MaterialNode extends Node {
 
 		} else if ( scope === MaterialNode.METALNESS ) {
 
-			const metalnessNode = this.getFloat( 'metalness' );
+			const metalnessNode = this.getFloat( scope );
 
 			if ( material.metalnessMap && material.metalnessMap.isTexture === true ) {
 
-				node = metalnessNode.mul( this.getTexture( 'metalnessMap' ).b );
+				node = metalnessNode.mul( this.getTexture( scope ).b );
 
 			} else {
 
@@ -134,11 +127,11 @@ class MaterialNode extends Node {
 
 		} else if ( scope === MaterialNode.EMISSIVE ) {
 
-			const emissiveNode = this.getColor( 'emissive' );
+			const emissiveNode = this.getColor( scope );
 
 			if ( material.emissiveMap && material.emissiveMap.isTexture === true ) {
 
-				node = emissiveNode.mul( this.getTexture( 'emissiveMap' ) );
+				node = emissiveNode.mul( this.getTexture( scope ) );
 
 			} else {
 
@@ -146,13 +139,29 @@ class MaterialNode extends Node {
 
 			}
 
+		} else if ( scope === MaterialNode.NORMAL ) {
+
+			if ( material.normalMap ) {
+
+				node = this.getTexture( 'normal' ).normalMap( this.getCache( 'normalScale', 'vec2' ) );
+
+			} else if ( material.bumpMap ) {
+
+				node = this.getTexture( 'bump' ).r.bumpMap( this.getFloat( 'bumpScale' ) );
+
+			} else {
+
+				node = normalView;
+
+			}
+
 		} else if ( scope === MaterialNode.CLEARCOAT ) {
 
-			const clearcoatNode = this.getFloat( 'clearcoat' );
+			const clearcoatNode = this.getFloat( scope );
 
 			if ( material.clearcoatMap && material.clearcoatMap.isTexture === true ) {
 
-				node = clearcoatNode.mul( this.getTexture( 'clearcoatMap' ).r );
+				node = clearcoatNode.mul( this.getTexture( scope ).r );
 
 			} else {
 
@@ -162,11 +171,11 @@ class MaterialNode extends Node {
 
 		} else if ( scope === MaterialNode.CLEARCOAT_ROUGHNESS ) {
 
-			const clearcoatRoughnessNode = this.getFloat( 'clearcoatRoughness' );
+			const clearcoatRoughnessNode = this.getFloat( scope );
 
 			if ( material.clearcoatRoughnessMap && material.clearcoatRoughnessMap.isTexture === true ) {
 
-				node = clearcoatRoughnessNode.mul( this.getTexture( 'clearcoatRoughnessMap' ).r );
+				node = clearcoatRoughnessNode.mul( this.getTexture( scope ).r );
 
 			} else {
 
@@ -174,13 +183,25 @@ class MaterialNode extends Node {
 
 			}
 
+		} else if ( scope === MaterialNode.CLEARCOAT_NORMAL ) {
+
+			if ( material.clearcoatNormalMap ) {
+
+				node = this.getTexture( scope ).normalMap( this.getCache( scope + 'Scale', 'vec2' ) );
+
+			} else {
+
+				node = normalView;
+
+			}
+
 		} else if ( scope === MaterialNode.SHEEN ) {
 
 			const sheenNode = this.getColor( 'sheenColor' ).mul( this.getFloat( 'sheen' ) ); // Move this mul() to CPU
 
 			if ( material.sheenColorMap && material.sheenColorMap.isTexture === true ) {
 
-				node = sheenNode.mul( this.getTexture( 'sheenColorMap' ).rgb );
+				node = sheenNode.mul( this.getTexture( 'sheenColor' ).rgb );
 
 			} else {
 
@@ -190,11 +211,11 @@ class MaterialNode extends Node {
 
 		} else if ( scope === MaterialNode.SHEEN_ROUGHNESS ) {
 
-			const sheenRoughnessNode = this.getFloat( 'sheenRoughness' );
+			const sheenRoughnessNode = this.getFloat( scope );
 
 			if ( material.sheenRoughnessMap && material.sheenRoughnessMap.isTexture === true ) {
 
-				node = sheenRoughnessNode.mul( this.getTexture( 'sheenRoughnessMap' ).a );
+				node = sheenRoughnessNode.mul( this.getTexture( scope ).a );
 
 			} else {
 
@@ -212,7 +233,7 @@ class MaterialNode extends Node {
 
 				const iridescenceThicknessMinimum = reference( 0, 'float', material.iridescenceThicknessRange );
 
-				node = iridescenceThicknessMaximum.sub( iridescenceThicknessMinimum ).mul( this.getTexture( 'iridescenceThicknessMap' ).g ).add( iridescenceThicknessMinimum );
+				node = iridescenceThicknessMaximum.sub( iridescenceThicknessMinimum ).mul( this.getTexture( scope ).g ).add( iridescenceThicknessMinimum );
 
 			} else {
 
@@ -224,7 +245,7 @@ class MaterialNode extends Node {
 
 			const outputType = this.getNodeType( builder );
 
-			node = materialReference( scope, outputType );
+			node = this.getCache( scope, outputType );
 
 		}
 
@@ -238,13 +259,15 @@ MaterialNode.ALPHA_TEST = 'alphaTest';
 MaterialNode.COLOR = 'color';
 MaterialNode.OPACITY = 'opacity';
 MaterialNode.SHININESS = 'shininess';
-MaterialNode.SPECULAR = 'specular';
+MaterialNode.SPECULAR_COLOR = 'specular';
 MaterialNode.SPECULAR_STRENGTH = 'specularStrength';
 MaterialNode.REFLECTIVITY = 'reflectivity';
 MaterialNode.ROUGHNESS = 'roughness';
 MaterialNode.METALNESS = 'metalness';
+MaterialNode.NORMAL = 'normal';
 MaterialNode.CLEARCOAT = 'clearcoat';
 MaterialNode.CLEARCOAT_ROUGHNESS = 'clearcoatRoughness';
+MaterialNode.CLEARCOAT_NORMAL = 'clearcoatNormal';
 MaterialNode.EMISSIVE = 'emissive';
 MaterialNode.ROTATION = 'rotation';
 MaterialNode.SHEEN = 'sheen';
@@ -252,6 +275,12 @@ MaterialNode.SHEEN_ROUGHNESS = 'sheenRoughness';
 MaterialNode.IRIDESCENCE = 'iridescence';
 MaterialNode.IRIDESCENCE_IOR = 'iridescenceIOR';
 MaterialNode.IRIDESCENCE_THICKNESS = 'iridescenceThickness';
+MaterialNode.LINE_SCALE = 'scale';
+MaterialNode.LINE_DASH_SIZE = 'dashSize';
+MaterialNode.LINE_GAP_SIZE = 'gapSize';
+MaterialNode.LINE_WIDTH = 'linewidth';
+MaterialNode.LINE_DASH_OFFSET = 'dashOffset';
+MaterialNode.POINT_WIDTH = 'pointWidth';
 
 export default MaterialNode;
 
@@ -265,13 +294,21 @@ export const materialSpecularStrength = nodeImmutable( MaterialNode, MaterialNod
 export const materialReflectivity = nodeImmutable( MaterialNode, MaterialNode.REFLECTIVITY );
 export const materialRoughness = nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS );
 export const materialMetalness = nodeImmutable( MaterialNode, MaterialNode.METALNESS );
+export const materialNormal = nodeImmutable( MaterialNode, MaterialNode.NORMAL );
 export const materialClearcoat = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT );
 export const materialClearcoatRoughness = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_ROUGHNESS );
+export const materialClearcoatNormal = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_NORMAL );
 export const materialRotation = nodeImmutable( MaterialNode, MaterialNode.ROTATION );
 export const materialSheen = nodeImmutable( MaterialNode, MaterialNode.SHEEN );
 export const materialSheenRoughness = nodeImmutable( MaterialNode, MaterialNode.SHEEN_ROUGHNESS );
 export const materialIridescence = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE );
 export const materialIridescenceIOR = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_IOR );
 export const materialIridescenceThickness = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_THICKNESS );
+export const materialLineScale = nodeImmutable( MaterialNode, MaterialNode.LINE_SCALE );
+export const materialLineDashSize = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_SIZE );
+export const materialLineGapSize = nodeImmutable( MaterialNode, MaterialNode.LINE_GAP_SIZE );
+export const materialLineWidth = nodeImmutable( MaterialNode, MaterialNode.LINE_WIDTH );
+export const materialLineDashOffset = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_OFFSET );
+export const materialPointWidth = nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH );
 
 addNodeClass( 'MaterialNode', MaterialNode );

+ 3 - 1
examples/jsm/nodes/display/BumpMapNode.js

@@ -4,7 +4,7 @@ import { uv } from '../accessors/UVNode.js';
 import { normalView } from '../accessors/NormalNode.js';
 import { positionView } from '../accessors/PositionNode.js';
 import { faceDirection } from './FrontFacingNode.js';
-import { tslFn, nodeProxy, float, vec2 } from '../shadernode/ShaderNode.js';
+import { addNodeElement, tslFn, nodeProxy, float, vec2 } from '../shadernode/ShaderNode.js';
 
 // Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen
 // https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf
@@ -94,4 +94,6 @@ export default BumpMapNode;
 
 export const bumpMap = nodeProxy( BumpMapNode );
 
+addNodeElement( 'bumpMap', bumpMap );
+
 addNodeClass( 'BumpMapNode', BumpMapNode );

+ 3 - 1
examples/jsm/nodes/display/NormalMapNode.js

@@ -8,7 +8,7 @@ import { tangentView } from '../accessors/TangentNode.js';
 import { uv } from '../accessors/UVNode.js';
 import { faceDirection } from './FrontFacingNode.js';
 import { addNodeClass } from '../core/Node.js';
-import { tslFn, nodeProxy, vec3, mat3 } from '../shadernode/ShaderNode.js';
+import { addNodeElement, tslFn, nodeProxy, vec3, mat3 } from '../shadernode/ShaderNode.js';
 
 import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from 'three';
 
@@ -103,4 +103,6 @@ export const normalMap = nodeProxy( NormalMapNode );
 
 export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
 
+addNodeElement( 'normalMap', normalMap );
+
 addNodeClass( 'NormalMapNode', NormalMapNode );

+ 1 - 2
examples/jsm/nodes/materials/FatPointsNodeMaterial.js

@@ -3,13 +3,12 @@ import { varying } from '../core/VaryingNode.js';
 import { property } from '../core/PropertyNode.js';
 import { attribute } from '../core/AttributeNode.js';
 import { cameraProjectionMatrix } from '../accessors/CameraNode.js';
-import { materialColor } from '../accessors/MaterialNode.js';
+import { materialColor, materialPointWidth } from '../accessors/MaterialNode.js'; // or should this be a property, instead?
 import { modelViewMatrix } from '../accessors/ModelNode.js';
 import { positionGeometry } from '../accessors/PositionNode.js';
 import { smoothstep } from '../math/MathNode.js';
 import { tslFn, vec2, vec4 } from '../shadernode/ShaderNode.js';
 import { uv } from '../accessors/UVNode.js';
-import { materialPointWidth } from '../accessors/FatPointsMaterialNode.js'; // or should this be a property, instead?
 import { viewport } from '../display/ViewportNode.js';
 import { color } from 'three/nodes';
 

+ 12 - 13
examples/jsm/nodes/materials/Line2NodeMaterial.js

@@ -4,13 +4,12 @@ import { varying } from '../core/VaryingNode.js';
 import { property } from '../core/PropertyNode.js';
 import { attribute } from '../core/AttributeNode.js';
 import { cameraProjectionMatrix } from '../accessors/CameraNode.js';
-import { materialColor } from '../accessors/MaterialNode.js';
+import { materialColor, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineDashOffset, materialLineWidth } from '../accessors/MaterialNode.js';
 import { modelViewMatrix } from '../accessors/ModelNode.js';
 import { positionGeometry } from '../accessors/PositionNode.js';
-import { abs, mix, mod, dot, clamp, smoothstep } from '../math/MathNode.js';
+import { mix, smoothstep } from '../math/MathNode.js';
 import { tslFn, float, vec2, vec3, vec4, If } from '../shadernode/ShaderNode.js';
 import { uv } from '../accessors/UVNode.js';
-import { materialLineScale, materialLineDashSize, materialLineGapSize, materialLineDashOffset, materialLineWidth } from '../accessors/LineMaterialNode.js';
 import { viewport } from '../display/ViewportNode.js';
 import { dashSize, gapSize } from '../core/PropertyNode.js';
 
@@ -240,17 +239,17 @@ class Line2NodeMaterial extends NodeMaterial {
 
 			const p21 = p2.sub( p1 );
 
-			const d1343 = dot( p13, p43 );
-			const d4321 = dot( p43, p21 );
-			const d1321 = dot( p13, p21 );
-			const d4343 = dot( p43, p43 );
-			const d2121 = dot( p21, p21 );
+			const d1343 = p13.dot( p43 );
+			const d4321 = p43.dot( p21 );
+			const d1321 = p13.dot( p21 );
+			const d4343 = p43.dot( p43 );
+			const d2121 = p21.dot( p21 );
 
 			const denom = d2121.mul( d4343 ).sub( d4321.mul( d4321 ) );
 			const numer = d1343.mul( d4321 ).sub( d1321.mul( d4343 ) );
 
-			const mua = clamp( numer.div( denom ), 0, 1 );
-			const mub = clamp( d1343.add( d4321.mul( mua ) ).div( d4343 ), 0, 1 );
+			const mua = numer.div( denom ).clamp();
+			const mub = d1343.add( d4321.mul( mua ) ).div( d4343 ).clamp();
 
 			return vec2( mua, mub );
 
@@ -279,7 +278,7 @@ class Line2NodeMaterial extends NodeMaterial {
 				const vLineDistanceOffset = offsetNode ? vLineDistance.add( offsetNode ) : vLineDistance;
 
 				vUv.y.lessThan( - 1.0 ).or( vUv.y.greaterThan( 1.0 ) ).discard(); // discard endcaps
-				mod( vLineDistanceOffset, dashSize.add( gapSize ) ).greaterThan( dashSize ).discard(); // todo - FIX
+				vLineDistanceOffset.mod( dashSize.add( gapSize ) ).greaterThan( dashSize ).discard(); // todo - FIX
 
 			}
 
@@ -333,7 +332,7 @@ class Line2NodeMaterial extends NodeMaterial {
 					const dlen = property( 'float', 'dlen' );
 					dlen.assign( len2.fwidth() );
 
-					If( abs( vUv.y ).greaterThan( 1.0 ), () => {
+					If( vUv.y.abs().greaterThan( 1.0 ), () => {
 
 						alpha.assign( smoothstep( dlen.oneMinus(), dlen.add( 1 ), len2 ).oneMinus() );
 
@@ -341,7 +340,7 @@ class Line2NodeMaterial extends NodeMaterial {
 
 				} else {
 
-					If( abs( vUv.y ).greaterThan( 1.0 ), () => {
+					If( vUv.y.abs().greaterThan( 1.0 ), () => {
 
 						const a = vUv.x;
 						const b = vUv.y.greaterThan( 0.0 ).cond( vUv.y.sub( 1.0 ), vUv.y.add( 1.0 ) );

+ 1 - 1
examples/jsm/nodes/materials/LineDashedNodeMaterial.js

@@ -1,7 +1,7 @@
 import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
 import { attribute } from '../core/AttributeNode.js';
 import { varying } from '../core/VaryingNode.js';
-import { materialLineDashSize, materialLineGapSize, materialLineScale } from '../accessors/LineMaterialNode.js';
+import { materialLineDashSize, materialLineGapSize, materialLineScale } from '../accessors/MaterialNode.js';
 import { dashSize, gapSize } from '../core/PropertyNode.js';
 import { float } from '../shadernode/ShaderNode.js';
 import { LineDashedMaterial } from 'three';

+ 1 - 2
examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js

@@ -1,8 +1,7 @@
 import { addNodeMaterial } from './NodeMaterial.js';
 import { transformedClearcoatNormalView } from '../accessors/NormalNode.js';
 import { clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness } from '../core/PropertyNode.js';
-import { materialClearcoatNormal } from '../accessors/ExtendedMaterialNode.js';
-import { materialClearcoat, materialClearcoatRoughness, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness } from '../accessors/MaterialNode.js';
+import { materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness } from '../accessors/MaterialNode.js';
 import { float, vec3 } from '../shadernode/ShaderNode.js';
 import PhysicalLightingModel from '../functions/PhysicalLightingModel.js';
 import MeshStandardNodeMaterial from './MeshStandardNodeMaterial.js';

+ 5 - 8
examples/jsm/nodes/materials/NodeMaterial.js

@@ -2,8 +2,7 @@ import { Material, ShaderMaterial, NoColorSpace, LinearSRGBColorSpace } from 'th
 import { getNodeChildren, getCacheKey } from '../core/NodeUtils.js';
 import { attribute } from '../core/AttributeNode.js';
 import { output, diffuseColor } from '../core/PropertyNode.js';
-import { materialNormal } from '../accessors/ExtendedMaterialNode.js';
-import { materialAlphaTest, materialColor, materialOpacity, materialEmissive } from '../accessors/MaterialNode.js';
+import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal } from '../accessors/MaterialNode.js';
 import { modelViewProjection } from '../accessors/ModelViewProjectionNode.js';
 import { transformedNormalView } from '../accessors/NormalNode.js';
 import { instance } from '../accessors/InstanceNode.js';
@@ -13,7 +12,7 @@ import { morph } from '../accessors/MorphNode.js';
 import { texture } from '../accessors/TextureNode.js';
 import { cubeTexture } from '../accessors/CubeTextureNode.js';
 import { lightsWithoutWrap } from '../lighting/LightsNode.js';
-import { mix, dFdx, dFdy } from '../math/MathNode.js';
+import { mix } from '../math/MathNode.js';
 import { float, vec3, vec4 } from '../shadernode/ShaderNode.js';
 import AONode from '../lighting/AONode.js';
 import { lightingContext } from '../lighting/LightingContextNode.js';
@@ -198,9 +197,7 @@ class NodeMaterial extends ShaderMaterial {
 
 		if ( this.flatShading === true ) {
 
-			const fdx = dFdx( positionView );
-			const fdy = dFdy( positionView );
-			const normalNode = fdx.cross( fdy ).normalize();
+			const normalNode = positionView.dFdx().cross( positionView.dFdy() ).normalize();
 
 			transformedNormalView.assign( normalNode );
 
@@ -289,9 +286,9 @@ class NodeMaterial extends ShaderMaterial {
 
 		if ( lightsNode && lightsNode.hasLight !== false ) {
 
-			const lightingModelNode = this.setupLightingModel( builder );
+			const lightingModel = this.setupLightingModel( builder );
 
-			outgoingLightNode = lightingContext( lightsNode, lightingModelNode, backdropNode, backdropAlphaNode );
+			outgoingLightNode = lightingContext( lightsNode, lightingModel, backdropNode, backdropAlphaNode );
 
 		} else if ( backdropNode !== null ) {