Skip to content

Commit

Permalink
NodeMaterial: unlit property (mrdoob#26429)
Browse files Browse the repository at this point in the history
* NodeMaterial: unlit property

* cleanup
  • Loading branch information
sunag committed Jul 14, 2023
1 parent 87d917b commit 6863177
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions examples/jsm/nodes/materials/NodeMaterial.js
@@ -1,4 +1,4 @@
import { Material, ShaderMaterial, NoColorSpace } from 'three';
import { Material, ShaderMaterial, NoColorSpace, LinearSRGBColorSpace } from 'three';
import { getNodeChildren, getCacheKey } from '../core/NodeUtils.js';
import { attribute } from '../core/AttributeNode.js';
import { output, diffuseColor } from '../core/PropertyNode.js';
Expand Down Expand Up @@ -34,6 +34,7 @@ class NodeMaterial extends ShaderMaterial {

this.lights = true;
this.normals = true;
this.unlit = this.constructor === NodeMaterial.prototype.constructor; // Extended materials are not unlit by default

this.lightsNode = null;
this.envNode = null;
Expand Down Expand Up @@ -78,7 +79,7 @@ class NodeMaterial extends ShaderMaterial {

let outputNode;

if ( this.isUnlit === false ) {
if ( this.unlit === false ) {

if ( this.normals === true ) this.constructNormal( builder );

Expand All @@ -89,6 +90,12 @@ class NodeMaterial extends ShaderMaterial {

outputNode = this.constructOutput( builder, vec4( outgoingLightNode, diffuseColor.a ) );

// OUTPUT NODE

builder.stack.assign( output, outputNode );

//

if ( this.outputNode !== null ) outputNode = this.outputNode;

} else {
Expand Down Expand Up @@ -336,18 +343,18 @@ class NodeMaterial extends ShaderMaterial {

}

if ( outputColorSpace !== NoColorSpace ) outputNode = outputNode.linearToColorSpace( outputColorSpace );
if ( outputColorSpace !== LinearSRGBColorSpace && outputColorSpace !== NoColorSpace ) {

outputNode = outputNode.linearToColorSpace( outputColorSpace );

}

// FOG

const fogNode = builder.fogNode;

if ( fogNode ) outputNode = vec4( fogNode.mixAssign( outputNode.rgb ), outputNode.a );

// OUTPUT NODE

builder.stack.assign( output, outputNode );

return outputNode;

}
Expand Down Expand Up @@ -447,12 +454,6 @@ class NodeMaterial extends ShaderMaterial {

}

get isUnlit() {

return this.constructor === NodeMaterial.prototype.constructor;

}

copy( source ) {

this.lightsNode = source.lightsNode;
Expand Down

0 comments on commit 6863177

Please sign in to comment.