|
@@ -13,7 +13,7 @@ import { positionLocal, positionView } from '../../nodes/accessors/Position.js';
|
|
|
import { skinning } from '../../nodes/accessors/SkinningNode.js';
|
|
import { skinning } from '../../nodes/accessors/SkinningNode.js';
|
|
|
import { morphReference } from '../../nodes/accessors/MorphNode.js';
|
|
import { morphReference } from '../../nodes/accessors/MorphNode.js';
|
|
|
import { mix } from '../../nodes/math/MathNode.js';
|
|
import { mix } from '../../nodes/math/MathNode.js';
|
|
|
-import { float, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
|
|
|
|
|
+import { float, vec3, vec4, bool } from '../../nodes/tsl/TSLBase.js';
|
|
|
import AONode from '../../nodes/lighting/AONode.js';
|
|
import AONode from '../../nodes/lighting/AONode.js';
|
|
|
import { lightingContext } from '../../nodes/lighting/LightingContextNode.js';
|
|
import { lightingContext } from '../../nodes/lighting/LightingContextNode.js';
|
|
|
import IrradianceNode from '../../nodes/lighting/IrradianceNode.js';
|
|
import IrradianceNode from '../../nodes/lighting/IrradianceNode.js';
|
|
@@ -229,6 +229,15 @@ class NodeMaterial extends Material {
|
|
|
*/
|
|
*/
|
|
|
this.alphaTestNode = null;
|
|
this.alphaTestNode = null;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Discards the fragment if the mask value is `false`.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @type {?Node<bool>}
|
|
|
|
|
+ * @default null
|
|
|
|
|
+ */
|
|
|
|
|
+ this.maskNode = null;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* The local vertex positions are computed based on multiple factors like the
|
|
* The local vertex positions are computed based on multiple factors like the
|
|
|
* attribute data, morphing or skinning. This node property allows to overwrite
|
|
* attribute data, morphing or skinning. This node property allows to overwrite
|
|
@@ -774,6 +783,14 @@ class NodeMaterial extends Material {
|
|
|
|
|
|
|
|
let colorNode = this.colorNode ? vec4( this.colorNode ) : materialColor;
|
|
let colorNode = this.colorNode ? vec4( this.colorNode ) : materialColor;
|
|
|
|
|
|
|
|
|
|
+ // MASK
|
|
|
|
|
+
|
|
|
|
|
+ if ( this.maskNode !== null ) {
|
|
|
|
|
+
|
|
|
|
|
+ bool( this.maskNode ).discard();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// VERTEX COLORS
|
|
// VERTEX COLORS
|
|
|
|
|
|
|
|
if ( this.vertexColors === true && geometry.hasAttribute( 'color' ) ) {
|
|
if ( this.vertexColors === true && geometry.hasAttribute( 'color' ) ) {
|
|
@@ -782,7 +799,7 @@ class NodeMaterial extends Material {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Instanced colors
|
|
|
|
|
|
|
+ // INSTANCED COLORS
|
|
|
|
|
|
|
|
if ( object.instanceColor ) {
|
|
if ( object.instanceColor ) {
|
|
|
|
|
|
|
@@ -800,7 +817,6 @@ class NodeMaterial extends Material {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
// COLOR
|
|
// COLOR
|
|
|
|
|
|
|
|
diffuseColor.assign( colorNode );
|
|
diffuseColor.assign( colorNode );
|
|
@@ -812,14 +828,20 @@ class NodeMaterial extends Material {
|
|
|
|
|
|
|
|
// ALPHA TEST
|
|
// ALPHA TEST
|
|
|
|
|
|
|
|
|
|
+ let alphaTestNode;
|
|
|
|
|
+
|
|
|
if ( this.alphaTestNode !== null || this.alphaTest > 0 ) {
|
|
if ( this.alphaTestNode !== null || this.alphaTest > 0 ) {
|
|
|
|
|
|
|
|
- const alphaTestNode = this.alphaTestNode !== null ? float( this.alphaTestNode ) : materialAlphaTest;
|
|
|
|
|
|
|
+ alphaTestNode = this.alphaTestNode !== null ? float( this.alphaTestNode ) : materialAlphaTest;
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
|
|
|
- diffuseColor.a.lessThanEqual( alphaTestNode ).discard();
|
|
|
|
|
|
|
+ alphaTestNode = float( 0 );
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ diffuseColor.a.lessThanEqual( alphaTestNode ).discard();
|
|
|
|
|
+
|
|
|
// ALPHA HASH
|
|
// ALPHA HASH
|
|
|
|
|
|
|
|
if ( this.alphaHash === true ) {
|
|
if ( this.alphaHash === true ) {
|
|
@@ -1189,6 +1211,7 @@ class NodeMaterial extends Material {
|
|
|
this.backdropNode = source.backdropNode;
|
|
this.backdropNode = source.backdropNode;
|
|
|
this.backdropAlphaNode = source.backdropAlphaNode;
|
|
this.backdropAlphaNode = source.backdropAlphaNode;
|
|
|
this.alphaTestNode = source.alphaTestNode;
|
|
this.alphaTestNode = source.alphaTestNode;
|
|
|
|
|
+ this.maskNode = source.maskNode;
|
|
|
|
|
|
|
|
this.positionNode = source.positionNode;
|
|
this.positionNode = source.positionNode;
|
|
|
this.geometryNode = source.geometryNode;
|
|
this.geometryNode = source.geometryNode;
|