Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeMaterial: unlit property #26429

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions examples/jsm/nodes/materials/NodeMaterial.js
Original file line number Diff line number Diff line change
@@ -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 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So output is not defined in the case of unlit materials?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because if unlit is true so material.outputNode is equal output.


//

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

} else {
Expand Down Expand Up @@ -328,18 +335,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 @@ -439,12 +446,6 @@ class NodeMaterial extends ShaderMaterial {

}

get isUnlit() {

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

}

copy( source ) {

this.lightsNode = source.lightsNode;
Expand Down