diff --git a/examples/jsm/nodes/Nodes.js b/examples/jsm/nodes/Nodes.js index 7ba5925e80795b..2d07b922cc4170 100644 --- a/examples/jsm/nodes/Nodes.js +++ b/examples/jsm/nodes/Nodes.js @@ -85,7 +85,7 @@ export { default as VertexColorNode, vertexColor } from './accessors/VertexColor export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js'; export { default as InstanceNode, instance } from './accessors/InstanceNode.js'; export { default as BatchNode, batch } from './accessors/BatchNode.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, materialAnisotropy, materialAnisotropyVector } from './accessors/MaterialNode.js'; +export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecular, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth, materialAnisotropy, materialAnisotropyVector } from './accessors/MaterialNode.js'; export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js'; export { default as RendererReferenceNode, rendererReference } from './accessors/RendererReferenceNode.js'; export { default as MorphNode, morphReference } from './accessors/MorphNode.js'; diff --git a/examples/jsm/nodes/accessors/MaterialNode.js b/examples/jsm/nodes/accessors/MaterialNode.js index 38ccb64f20bbc6..402e30f671d11b 100644 --- a/examples/jsm/nodes/accessors/MaterialNode.js +++ b/examples/jsm/nodes/accessors/MaterialNode.js @@ -113,6 +113,20 @@ class MaterialNode extends Node { } + } else if ( scope === MaterialNode.SPECULAR_COLOR ) { + + const specularColorNode = this.getColor( scope ); + + if ( material.specularColorMap && material.specularColorMap.isTexture === true ) { + + node = specularColorNode.mul( this.getTexture( scope ).rgb ); + + } else { + + node = specularColorNode; + + } + } else if ( scope === MaterialNode.ROUGHNESS ) { // TODO: cleanup similar branches const roughnessNode = this.getFloat( scope ); @@ -322,10 +336,10 @@ MaterialNode.ALPHA_TEST = 'alphaTest'; MaterialNode.COLOR = 'color'; MaterialNode.OPACITY = 'opacity'; MaterialNode.SHININESS = 'shininess'; -MaterialNode.SPECULAR_COLOR = 'specular'; +MaterialNode.SPECULAR = 'specular'; MaterialNode.SPECULAR_STRENGTH = 'specularStrength'; MaterialNode.SPECULAR_INTENSITY = 'specularIntensity'; -MaterialNode.SPECULAR_COLOR2 = 'specularColor'; +MaterialNode.SPECULAR_COLOR = 'specularColor'; MaterialNode.REFLECTIVITY = 'reflectivity'; MaterialNode.ROUGHNESS = 'roughness'; MaterialNode.METALNESS = 'metalness'; @@ -360,10 +374,10 @@ export const materialColor = nodeImmutable( MaterialNode, MaterialNode.COLOR ); export const materialShininess = nodeImmutable( MaterialNode, MaterialNode.SHININESS ); export const materialEmissive = nodeImmutable( MaterialNode, MaterialNode.EMISSIVE ); export const materialOpacity = nodeImmutable( MaterialNode, MaterialNode.OPACITY ); -export const materialSpecularColor = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_COLOR ); +export const materialSpecular = nodeImmutable( MaterialNode, MaterialNode.SPECULAR ); export const materialSpecularIntensity = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_INTENSITY ); -export const materialSpecularColor2 = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_COLOR2 ); +export const materialSpecularColor = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_COLOR ); export const materialSpecularStrength = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_STRENGTH ); export const materialReflectivity = nodeImmutable( MaterialNode, MaterialNode.REFLECTIVITY ); diff --git a/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js b/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js index 42a04297bf7efe..54cdb470516486 100644 --- a/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +++ b/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js @@ -1,6 +1,6 @@ import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js'; import { shininess, specularColor } from '../core/PropertyNode.js'; -import { materialShininess, materialSpecularColor } from '../accessors/MaterialNode.js'; +import { materialShininess, materialSpecular } from '../accessors/MaterialNode.js'; import { float } from '../shadernode/ShaderNode.js'; import PhongLightingModel from '../functions/PhongLightingModel.js'; @@ -43,7 +43,7 @@ class MeshPhongNodeMaterial extends NodeMaterial { // SPECULAR COLOR - const specularNode = this.specularNode || materialSpecularColor; + const specularNode = this.specularNode || materialSpecular; specularColor.assign( specularNode ); diff --git a/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js b/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js index 6dbcaf0630a075..ace2f9b620663e 100644 --- a/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +++ b/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js @@ -1,7 +1,7 @@ import { addNodeMaterial } from './NodeMaterial.js'; import { transformedClearcoatNormalView } from '../accessors/NormalNode.js'; import { clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, specularColor, specularF90, diffuseColor, metalness, roughness, anisotropy, alphaT, anisotropyT, anisotropyB, ior, transmission, thickness, attenuationDistance, attenuationColor } from '../core/PropertyNode.js'; -import { materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialSpecularIntensity, materialSpecularColor2, materialAnisotropy, materialIOR, materialTransmission, materialThickness, materialAttenuationDistance, materialAttenuationColor } from '../accessors/MaterialNode.js'; +import { materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialSpecularIntensity, materialSpecularColor, materialAnisotropy, materialIOR, materialTransmission, materialThickness, materialAttenuationDistance, materialAttenuationColor } from '../accessors/MaterialNode.js'; import { float, vec2, vec3, If } from '../shadernode/ShaderNode.js'; import { TBNViewMatrix } from '../accessors/AccessorsUtils.js'; import PhysicalLightingModel from '../functions/PhysicalLightingModel.js'; @@ -82,7 +82,7 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial { const iorNode = this.iorNode ? float( this.iorNode ) : materialIOR; ior.assign( iorNode ); - specularColor.assign( mix( min( pow2( ior.sub( 1.0 ).div( ior.add( 1.0 ) ) ).mul( materialSpecularColor2 ), vec3( 1.0 ) ).mul( materialSpecularIntensity ), diffuseColor.rgb, metalness ) ); + specularColor.assign( mix( min( pow2( ior.sub( 1.0 ).div( ior.add( 1.0 ) ) ).mul( materialSpecularColor ), vec3( 1.0 ) ).mul( materialSpecularIntensity ), diffuseColor.rgb, metalness ) ); specularF90.assign( mix( materialSpecularIntensity, 1.0, metalness ) ); }