|
|
@@ -6,11 +6,11 @@ import { attribute } from '../core/AttributeNode.js';
|
|
|
import { output, diffuseColor, emissive, varyingProperty } from '../core/PropertyNode.js';
|
|
|
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap, materialAOMap } from '../accessors/MaterialNode.js';
|
|
|
import { modelViewProjection } from '../accessors/ModelViewProjectionNode.js';
|
|
|
-import { transformedNormalView, normalLocal } from '../accessors/NormalNode.js';
|
|
|
+import { normalLocal } from '../accessors/NormalNode.js';
|
|
|
import { instance } from '../accessors/InstanceNode.js';
|
|
|
import { batch } from '../accessors/BatchNode.js';
|
|
|
import { materialReference } from '../accessors/MaterialReferenceNode.js';
|
|
|
-import { positionLocal, positionView } from '../accessors/PositionNode.js';
|
|
|
+import { positionLocal } from '../accessors/PositionNode.js';
|
|
|
import { skinningReference } from '../accessors/SkinningNode.js';
|
|
|
import { morphReference } from '../accessors/MorphNode.js';
|
|
|
import { lightsNode } from '../lighting/LightsNode.js';
|
|
|
@@ -22,7 +22,6 @@ import IrradianceNode from '../lighting/IrradianceNode.js';
|
|
|
import { depth } from '../display/ViewportDepthNode.js';
|
|
|
import { cameraLogDepth } from '../accessors/CameraNode.js';
|
|
|
import { clipping, clippingAlpha } from '../accessors/ClippingNode.js';
|
|
|
-import { faceDirection } from '../display/FrontFacingNode.js';
|
|
|
|
|
|
const NodeMaterials = new Map();
|
|
|
|
|
|
@@ -40,7 +39,6 @@ class NodeMaterial extends Material {
|
|
|
|
|
|
this.fog = true;
|
|
|
this.lights = false;
|
|
|
- this.normals = true;
|
|
|
|
|
|
this.lightsNode = null;
|
|
|
this.envNode = null;
|
|
|
@@ -81,6 +79,8 @@ class NodeMaterial extends Material {
|
|
|
|
|
|
setup( builder ) {
|
|
|
|
|
|
+ builder.context.setupNormal = () => this.setupNormal( builder );
|
|
|
+
|
|
|
// < VERTEX STAGE >
|
|
|
|
|
|
builder.addStack();
|
|
|
@@ -101,8 +101,6 @@ class NodeMaterial extends Material {
|
|
|
|
|
|
if ( this.fragmentNode === null ) {
|
|
|
|
|
|
- if ( this.normals === true ) this.setupNormal( builder );
|
|
|
-
|
|
|
this.setupDiffuseColor( builder );
|
|
|
this.setupVariants( builder );
|
|
|
|
|
|
@@ -345,7 +343,6 @@ class NodeMaterial extends Material {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
setupOutgoingLight() {
|
|
|
|
|
|
return ( this.lights === true ) ? vec3( 0 ) : diffuseColor.rgb;
|
|
|
@@ -354,21 +351,7 @@ class NodeMaterial extends Material {
|
|
|
|
|
|
setupNormal() {
|
|
|
|
|
|
- // NORMAL VIEW
|
|
|
-
|
|
|
- if ( this.flatShading === true ) {
|
|
|
-
|
|
|
- const normalNode = positionView.dFdx().cross( positionView.dFdy() ).normalize();
|
|
|
-
|
|
|
- transformedNormalView.assign( normalNode.mul( faceDirection ) );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- const normalNode = this.normalNode ? vec3( this.normalNode ) : materialNormal;
|
|
|
-
|
|
|
- transformedNormalView.assign( normalNode.mul( faceDirection ) );
|
|
|
-
|
|
|
- }
|
|
|
+ return this.normalNode ? vec3( this.normalNode ) : materialNormal;
|
|
|
|
|
|
}
|
|
|
|