@@ -13,7 +13,7 @@ import { positionLocal, positionView } from '../../nodes/accessors/Position.js';
13
13
import { skinning } from '../../nodes/accessors/SkinningNode.js' ;
14
14
import { morphReference } from '../../nodes/accessors/MorphNode.js' ;
15
15
import { mix } from '../../nodes/math/MathNode.js' ;
16
- import { float , vec3 , vec4 } from '../../nodes/tsl/TSLBase.js' ;
16
+ import { float , vec3 , vec4 , bool } from '../../nodes/tsl/TSLBase.js' ;
17
17
import AONode from '../../nodes/lighting/AONode.js' ;
18
18
import { lightingContext } from '../../nodes/lighting/LightingContextNode.js' ;
19
19
import IrradianceNode from '../../nodes/lighting/IrradianceNode.js' ;
@@ -229,6 +229,15 @@ class NodeMaterial extends Material {
229
229
*/
230
230
this . alphaTestNode = null ;
231
231
232
+
233
+ /**
234
+ * Discards the fragment if the mask value is `false`.
235
+ *
236
+ * @type {?Node<bool> }
237
+ * @default null
238
+ */
239
+ this . maskNode = null ;
240
+
232
241
/**
233
242
* The local vertex positions are computed based on multiple factors like the
234
243
* attribute data, morphing or skinning. This node property allows to overwrite
@@ -774,6 +783,14 @@ class NodeMaterial extends Material {
774
783
775
784
let colorNode = this . colorNode ? vec4 ( this . colorNode ) : materialColor ;
776
785
786
+ // MASK
787
+
788
+ if ( this . maskNode !== null ) {
789
+
790
+ bool ( this . maskNode ) . discard ( ) ;
791
+
792
+ }
793
+
777
794
// VERTEX COLORS
778
795
779
796
if ( this . vertexColors === true && geometry . hasAttribute ( 'color' ) ) {
@@ -1194,6 +1211,7 @@ class NodeMaterial extends Material {
1194
1211
this . backdropNode = source . backdropNode ;
1195
1212
this . backdropAlphaNode = source . backdropAlphaNode ;
1196
1213
this . alphaTestNode = source . alphaTestNode ;
1214
+ this . maskNode = source . maskNode ;
1197
1215
1198
1216
this . positionNode = source . positionNode ;
1199
1217
this . geometryNode = source . geometryNode ;
0 commit comments