Skip to content

Commit

Permalink
MeshStandardNodeMaterial: Fix specular color node. (#25700)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Mar 22, 2023
1 parent 464e9ad commit 946f27f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions examples/jsm/nodes/materials/MeshStandardNodeMaterial.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
import { diffuseColor, metalness, roughness, specularColor } from '../core/PropertyNode.js';
import { mix } from '../math/MathNode.js';
import { materialRoughness, materialMetalness, materialColor } from '../accessors/MaterialNode.js';
import { materialRoughness, materialMetalness } from '../accessors/MaterialNode.js';
import getRoughness from '../functions/material/getRoughness.js';
import physicalLightingModel from '../functions/PhysicalLightingModel.js';
import { float, vec3, vec4 } from '../shadernode/ShaderNode.js';
Expand Down Expand Up @@ -55,7 +55,6 @@ class MeshStandardNodeMaterial extends NodeMaterial {
const metalnessNode = this.metalnessNode ? float( this.metalnessNode ) : materialMetalness;

stack.assign( metalness, metalnessNode );
stack.assign( diffuseColor, vec4( diffuseColor.rgb.mul( metalnessNode.invert() ), diffuseColor.a ) );

// ROUGHNESS

Expand All @@ -66,10 +65,14 @@ class MeshStandardNodeMaterial extends NodeMaterial {

// SPECULAR COLOR

const specularColorNode = mix( vec3( 0.04 ), materialColor.rgb, metalnessNode );
const specularColorNode = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessNode );

stack.assign( specularColor, specularColorNode );

// DIFFUSE COLOR

stack.assign( diffuseColor, vec4( diffuseColor.rgb.mul( metalnessNode.invert() ), diffuseColor.a ) );

}

copy( source ) {
Expand Down

0 comments on commit 946f27f

Please sign in to comment.