|
@@ -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';
|
|
@@ -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;
|
|
@@ -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 );
|
|
|
|
|
@@ -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 {
|
|
@@ -328,7 +335,11 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( outputColorSpace !== NoColorSpace ) outputNode = outputNode.linearToColorSpace( outputColorSpace );
|
|
|
+ if ( outputColorSpace !== LinearSRGBColorSpace && outputColorSpace !== NoColorSpace ) {
|
|
|
+
|
|
|
+ outputNode = outputNode.linearToColorSpace( outputColorSpace );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
// FOG
|
|
|
|
|
@@ -336,10 +347,6 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
|
|
|
if ( fogNode ) outputNode = vec4( fogNode.mixAssign( outputNode.rgb ), outputNode.a );
|
|
|
|
|
|
- // OUTPUT NODE
|
|
|
-
|
|
|
- builder.stack.assign( output, outputNode );
|
|
|
-
|
|
|
return outputNode;
|
|
|
|
|
|
}
|
|
@@ -439,12 +446,6 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
|
|
|
}
|
|
|
|
|
|
- get isUnlit() {
|
|
|
-
|
|
|
- return this.constructor === NodeMaterial.prototype.constructor;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
copy( source ) {
|
|
|
|
|
|
this.lightsNode = source.lightsNode;
|