From 89fab2161dd7ca91e8580eda925d6226311ab97f Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Fri, 13 Sep 2024 16:29:42 -0700 Subject: [PATCH] Better alpha handling --- .../Background/backgroundMaterial.ts | 2 +- .../core/src/Materials/PBR/pbrBaseMaterial.ts | 59 ++++++------------ packages/dev/core/src/Materials/material.ts | 61 ++++++++++--------- .../dev/core/src/Materials/shaderMaterial.ts | 2 +- .../core/src/Materials/standardMaterial.ts | 48 +++------------ .../ShadersInclude/pbrBlockAlbedoOpacity.fx | 2 +- .../ShadersInclude/pbrBlockAlphaFresnel.fx | 2 +- .../src/Shaders/glowMapGeneration.fragment.fx | 2 +- .../core/src/Shaders/shadowMap.fragment.fx | 2 +- .../ShadersInclude/pbrBlockAlbedoOpacity.fx | 2 +- .../ShadersInclude/pbrBlockAlphaFresnel.fx | 2 +- .../ShadersWGSL/glowMapGeneration.fragment.fx | 2 +- .../src/ShadersWGSL/shadowMap.fragment.fx | 2 +- .../dev/materials/src/cell/cellMaterial.ts | 2 +- packages/dev/materials/src/fur/furMaterial.ts | 2 +- .../src/gradient/gradientMaterial.ts | 2 +- .../dev/materials/src/lava/lavaMaterial.ts | 2 +- packages/dev/materials/src/mix/mixMaterial.ts | 2 +- .../materials/src/normal/normalMaterial.ts | 2 +- .../src/shadowOnly/shadowOnlyMaterial.ts | 2 +- .../materials/src/simple/simpleMaterial.ts | 2 +- .../materials/src/terrain/terrainMaterial.ts | 2 +- .../src/triPlanar/triPlanarMaterial.ts | 2 +- .../dev/materials/src/water/waterMaterial.ts | 2 +- 24 files changed, 79 insertions(+), 131 deletions(-) diff --git a/packages/dev/core/src/Materials/Background/backgroundMaterial.ts b/packages/dev/core/src/Materials/Background/backgroundMaterial.ts index ba1d393a4393..0cf9adc9ec29 100644 --- a/packages/dev/core/src/Materials/Background/backgroundMaterial.ts +++ b/packages/dev/core/src/Materials/Background/backgroundMaterial.ts @@ -902,7 +902,7 @@ export class BackgroundMaterial extends PushMaterial { } // Misc. - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); // Values that need to be evaluated on every frame PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances, null, subMesh.getRenderingMesh().hasThinInstances); diff --git a/packages/dev/core/src/Materials/PBR/pbrBaseMaterial.ts b/packages/dev/core/src/Materials/PBR/pbrBaseMaterial.ts index a178447dd6a9..cdc6562317e2 100644 --- a/packages/dev/core/src/Materials/PBR/pbrBaseMaterial.ts +++ b/packages/dev/core/src/Materials/PBR/pbrBaseMaterial.ts @@ -721,12 +721,6 @@ export abstract class PBRBaseMaterial extends PushMaterial { */ public _alphaCutOff = 0.4; - /** - * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations. - * @internal - */ - public override _forceAlphaTest = false; - /** * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel) @@ -1008,55 +1002,38 @@ export abstract class PBRBaseMaterial extends PushMaterial { return "PBRBaseMaterial"; } - /** - * Returns true if alpha blending should be disabled. - */ - protected override get _disableAlphaBlending(): boolean { - return ( - this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE || - this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST || - this.subSurface?.disableAlphaBlending - ); + protected _shouldUseAlphaFromAlbedoTexture(): boolean { + return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE; } - /** - * @returns whether or not this material should be rendered in alpha blend mode. - */ + protected override _hasAlpha(mesh: AbstractMesh): boolean { + return super._hasAlpha(mesh) || this._shouldUseAlphaFromAlbedoTexture() || this._opacityTexture != null; + } + + /** @override */ public override needAlphaBlending(): boolean { - if (this._disableAlphaBlending) { + if (this._hasTransparencyMode) { + return this._transparencyModeIsBlend; + } + + if (this.subSurface?.disableAlphaBlending) { return false; } - return this.alpha < 1.0 || this._opacityTexture != null || this._shouldUseAlphaFromAlbedoTexture(); + return super.needAlphaBlending(); } - /** - * @returns whether or not this material should be rendered in alpha test mode. - */ + /** @override */ public override needAlphaTesting(): boolean { - if (this._forceAlphaTest) { - return true; + if (this._hasTransparencyMode) { + return this._transparencyModeIsTest; } if (this.subSurface?.disableAlphaBlending) { return false; } - return this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST); - } - - /** - * @returns whether or not the alpha value of the albedo texture should be used for alpha blending. - */ - protected _shouldUseAlphaFromAlbedoTexture(): boolean { - return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE; - } - - /** - * @returns whether or not there is a usable alpha channel for transparency. - */ - protected _hasAlphaChannel(): boolean { - return (this._albedoTexture != null && this._albedoTexture.hasAlpha) || this._opacityTexture != null; + return super.needAlphaTesting(); } /** @@ -1897,7 +1874,7 @@ export abstract class PBRBaseMaterial extends PushMaterial { this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, - this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, + this.needAlphaTestingForMesh(mesh), defines, this._applyDecalMapAfterDetailMap ); diff --git a/packages/dev/core/src/Materials/material.ts b/packages/dev/core/src/Materials/material.ts index 86bd80bc7319..19452624452f 100644 --- a/packages/dev/core/src/Materials/material.ts +++ b/packages/dev/core/src/Materials/material.ts @@ -1058,11 +1058,6 @@ export class Material implements IAnimatable, IClipPlanesHolder { return this.sideOrientation !== null ? this.sideOrientation : mesh.sideOrientation; } - /** - * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations. - */ - protected _forceAlphaTest = false; - /** * The transparency mode of the material. */ @@ -1094,16 +1089,23 @@ export class Material implements IAnimatable, IClipPlanesHolder { this._transparencyMode = value; - this._forceAlphaTest = value === Material.MATERIAL_ALPHATESTANDBLEND; - this._markAllSubMeshesAsTexturesAndMiscDirty(); } - /** - * Returns true if alpha blending should be disabled. - */ - protected get _disableAlphaBlending(): boolean { - return this._transparencyMode === Material.MATERIAL_OPAQUE || this._transparencyMode === Material.MATERIAL_ALPHATEST; + protected get _hasTransparencyMode(): boolean { + return this._transparencyMode != null; + } + + protected get _transparencyModeIsBlend(): boolean { + return this._transparencyMode === Material.MATERIAL_ALPHABLEND || this._transparencyMode === Material.MATERIAL_ALPHATESTANDBLEND; + } + + protected get _transparencyModeIsTest(): boolean { + return this._transparencyMode === Material.MATERIAL_ALPHATEST || this._transparencyMode === Material.MATERIAL_ALPHATESTANDBLEND; + } + + protected _hasAlpha(mesh: AbstractMesh): boolean { + return this.alpha < 1.0 || mesh.hasVertexAlpha; } /** @@ -1111,8 +1113,8 @@ export class Material implements IAnimatable, IClipPlanesHolder { * @returns a boolean specifying if alpha blending is needed */ public needAlphaBlending(): boolean { - if (this._disableAlphaBlending) { - return false; + if (this._hasTransparencyMode) { + return this._transparencyModeIsBlend; } return this.alpha < 1.0; @@ -1124,15 +1126,15 @@ export class Material implements IAnimatable, IClipPlanesHolder { * @returns a boolean specifying if alpha blending is needed for the mesh */ public needAlphaBlendingForMesh(mesh: AbstractMesh): boolean { - if (mesh.visibility < 1.0) { - return true; + if (this._hasTransparencyMode) { + return this._transparencyModeIsBlend; } - if (this._disableAlphaBlending) { - return false; + if (this.needAlphaBlending()) { + return true; } - return mesh.hasVertexAlpha || this.needAlphaBlending(); + return this._hasAlpha(mesh) || mesh.visibility < 1.0; } /** @@ -1140,8 +1142,8 @@ export class Material implements IAnimatable, IClipPlanesHolder { * @returns a boolean specifying if an alpha test is needed. */ public needAlphaTesting(): boolean { - if (this._forceAlphaTest) { - return true; + if (this._hasTransparencyMode) { + return this._transparencyModeIsTest; } return false; @@ -1153,16 +1155,15 @@ export class Material implements IAnimatable, IClipPlanesHolder { * @returns a boolean specifying if an alpha test is needed. */ public needAlphaTestingForMesh(mesh: AbstractMesh): boolean { - return mesh.hasVertexAlpha || this.needAlphaTesting(); - } + if (this._hasTransparencyMode) { + return this._transparencyModeIsTest; + } - /** - * Specifies if material alpha testing should be turned on for the mesh - * @param mesh defines the mesh to check - * @returns a boolean specifying if alpha testing should be turned on for the mesh - */ - protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean { - return !this.needAlphaBlendingForMesh(mesh) && this.needAlphaTestingForMesh(mesh); + if (this.needAlphaTesting()) { + return true; + } + + return this._hasAlpha(mesh); } /** diff --git a/packages/dev/core/src/Materials/shaderMaterial.ts b/packages/dev/core/src/Materials/shaderMaterial.ts index 2d5d898ae7b6..5ac40ae054b4 100644 --- a/packages/dev/core/src/Materials/shaderMaterial.ts +++ b/packages/dev/core/src/Materials/shaderMaterial.ts @@ -847,7 +847,7 @@ export class ShaderMaterial extends PushMaterial { } // Alpha test - if (mesh && this._shouldTurnAlphaTestOn(mesh)) { + if (mesh && this.needAlphaTestingForMesh(mesh)) { defines.push("#define ALPHATEST"); } diff --git a/packages/dev/core/src/Materials/standardMaterial.ts b/packages/dev/core/src/Materials/standardMaterial.ts index 326b26dc20cc..9d0c93a959fa 100644 --- a/packages/dev/core/src/Materials/standardMaterial.ts +++ b/packages/dev/core/src/Materials/standardMaterial.ts @@ -871,47 +871,17 @@ export class StandardMaterial extends PushMaterial { return "StandardMaterial"; } - /** - * Specifies if the material will require alpha blending - * @returns a boolean specifying if alpha blending is needed - */ - public override needAlphaBlending(): boolean { - if (this._disableAlphaBlending) { - return false; - } - - return ( - this.alpha < 1.0 || - this._opacityTexture != null || - this._shouldUseAlphaFromDiffuseTexture() || - (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled) - ); - } - - /** - * Specifies if this material should be rendered in alpha test mode - * @returns a boolean specifying if an alpha test is needed. - */ - public override needAlphaTesting(): boolean { - if (this._forceAlphaTest) { - return true; - } - - return this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === Material.MATERIAL_ALPHATEST); - } - - /** - * @returns whether or not the alpha value of the diffuse texture should be used for alpha blending. - */ protected _shouldUseAlphaFromDiffuseTexture(): boolean { return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture && this._transparencyMode !== Material.MATERIAL_OPAQUE; } - /** - * @returns whether or not there is a usable alpha channel for transparency. - */ - protected _hasAlphaChannel(): boolean { - return (this._diffuseTexture != null && this._diffuseTexture.hasAlpha) || this._opacityTexture != null; + protected override _hasAlpha(mesh: AbstractMesh): boolean { + return super._hasAlpha(mesh) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityTexture != null; + } + + /** @override */ + public override needAlphaBlending(): boolean { + return super.needAlphaBlending() || this._opacityFresnelParameters?.isEnabled; } /** @@ -1224,7 +1194,7 @@ export class StandardMaterial extends PushMaterial { this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, - this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, + this.needAlphaTestingForMesh(mesh), defines, this._applyDecalMapAfterDetailMap ); @@ -1686,7 +1656,7 @@ export class StandardMaterial extends PushMaterial { BindTextureMatrix(this._opacityTexture, ubo, "opacity"); } - if (this._hasAlphaChannel()) { + if (this._hasAlpha(mesh)) { ubo.updateFloat("alphaCutOff", this.alphaCutOff); } diff --git a/packages/dev/core/src/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.fx b/packages/dev/core/src/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.fx index 9b6827b904a6..3be11d5f0ebf 100644 --- a/packages/dev/core/src/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.fx +++ b/packages/dev/core/src/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.fx @@ -81,7 +81,7 @@ albedoOpacityOutParams albedoOpacityBlock( #if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) #ifdef ALPHATEST #if DEBUGMODE != 88 - if (alpha < ALPHATESTVALUE) + if (alpha + 0.0000001 < ALPHATESTVALUE) discard; #endif diff --git a/packages/dev/core/src/Shaders/ShadersInclude/pbrBlockAlphaFresnel.fx b/packages/dev/core/src/Shaders/ShadersInclude/pbrBlockAlphaFresnel.fx index 999313bf501b..cc67b0b6c1f3 100644 --- a/packages/dev/core/src/Shaders/ShadersInclude/pbrBlockAlphaFresnel.fx +++ b/packages/dev/core/src/Shaders/ShadersInclude/pbrBlockAlphaFresnel.fx @@ -33,7 +33,7 @@ outParams.alpha = getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW, normalForward)), vec3(opacity0), vec3(opacity90), sqrt(microSurface)).x; #ifdef ALPHATEST - if (outParams.alpha < ALPHATESTVALUE) + if (outParams.alpha + 0.0000001 < ALPHATESTVALUE) discard; #ifndef ALPHABLEND diff --git a/packages/dev/core/src/Shaders/glowMapGeneration.fragment.fx b/packages/dev/core/src/Shaders/glowMapGeneration.fragment.fx index 3ab355b85e30..235860554cd5 100644 --- a/packages/dev/core/src/Shaders/glowMapGeneration.fragment.fx +++ b/packages/dev/core/src/Shaders/glowMapGeneration.fragment.fx @@ -71,7 +71,7 @@ vec4 finalColor = glowColor; #endif #ifdef ALPHATEST - if (finalColor.a < ALPHATESTVALUE) + if (finalColor.a + 0.0000001 < ALPHATESTVALUE) discard; #endif diff --git a/packages/dev/core/src/Shaders/shadowMap.fragment.fx b/packages/dev/core/src/Shaders/shadowMap.fragment.fx index eb478178ae3e..70652be88b03 100644 --- a/packages/dev/core/src/Shaders/shadowMap.fragment.fx +++ b/packages/dev/core/src/Shaders/shadowMap.fragment.fx @@ -27,7 +27,7 @@ void main(void) #endif #ifdef ALPHATESTVALUE - if (alphaFromAlphaTexture < ALPHATESTVALUE) + if (alphaFromAlphaTexture + 0.0000001 < ALPHATESTVALUE) discard; #endif #endif diff --git a/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockAlbedoOpacity.fx b/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockAlbedoOpacity.fx index da3bd45fd27c..e17471e6f182 100644 --- a/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockAlbedoOpacity.fx +++ b/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockAlbedoOpacity.fx @@ -81,7 +81,7 @@ fn albedoOpacityBlock( #if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) #ifdef ALPHATEST #if DEBUGMODE != 88 - if (alpha < ALPHATESTVALUE) { + if (alpha + 0.0000001 < ALPHATESTVALUE) { discard; } #endif diff --git a/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockAlphaFresnel.fx b/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockAlphaFresnel.fx index 56787a8dad59..643e205d58d6 100644 --- a/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockAlphaFresnel.fx +++ b/packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockAlphaFresnel.fx @@ -36,7 +36,7 @@ outParams.alpha = getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW, normalForward)), vec3f(opacity0), vec3f(opacity90), sqrt(microSurface)).x; #ifdef ALPHATEST - if (outParams.alpha < ALPHATESTVALUE) { + if (outParams.alpha + 0.0000001 < ALPHATESTVALUE) { discard; } diff --git a/packages/dev/core/src/ShadersWGSL/glowMapGeneration.fragment.fx b/packages/dev/core/src/ShadersWGSL/glowMapGeneration.fragment.fx index 3ad05fe9455e..d36fcc58433d 100644 --- a/packages/dev/core/src/ShadersWGSL/glowMapGeneration.fragment.fx +++ b/packages/dev/core/src/ShadersWGSL/glowMapGeneration.fragment.fx @@ -74,7 +74,7 @@ var finalColor: vec4f = uniforms.glowColor; #endif #ifdef ALPHATEST - if (finalColor.a < ALPHATESTVALUE) + if (finalColor.a + 0.0000001 < ALPHATESTVALUE) discard; #endif diff --git a/packages/dev/core/src/ShadersWGSL/shadowMap.fragment.fx b/packages/dev/core/src/ShadersWGSL/shadowMap.fragment.fx index c576896fbf92..5daab8684a27 100644 --- a/packages/dev/core/src/ShadersWGSL/shadowMap.fragment.fx +++ b/packages/dev/core/src/ShadersWGSL/shadowMap.fragment.fx @@ -28,7 +28,7 @@ fn main(input: FragmentInputs) -> FragmentOutputs { #endif #ifdef ALPHATESTVALUE - if (alphaFromAlphaTexture < ALPHATESTVALUE) { + if (alphaFromAlphaTexture + 0.0000001 < ALPHATESTVALUE) { discard; } #endif diff --git a/packages/dev/materials/src/cell/cellMaterial.ts b/packages/dev/materials/src/cell/cellMaterial.ts index cff176a2628f..57b208893c18 100644 --- a/packages/dev/materials/src/cell/cellMaterial.ts +++ b/packages/dev/materials/src/cell/cellMaterial.ts @@ -152,7 +152,7 @@ export class CellMaterial extends PushMaterial { defines.CELLBASIC = !this.computeHighLevel; // Misc. - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); // Lights defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting); diff --git a/packages/dev/materials/src/fur/furMaterial.ts b/packages/dev/materials/src/fur/furMaterial.ts index b5360a50ae7b..b498fcc49fe7 100644 --- a/packages/dev/materials/src/fur/furMaterial.ts +++ b/packages/dev/materials/src/fur/furMaterial.ts @@ -228,7 +228,7 @@ export class FurMaterial extends PushMaterial { } // Misc. - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); // Lights defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting); diff --git a/packages/dev/materials/src/gradient/gradientMaterial.ts b/packages/dev/materials/src/gradient/gradientMaterial.ts index e23b0316c018..0fbe89e1520e 100644 --- a/packages/dev/materials/src/gradient/gradientMaterial.ts +++ b/packages/dev/materials/src/gradient/gradientMaterial.ts @@ -142,7 +142,7 @@ export class GradientMaterial extends PushMaterial { PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false); - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting); diff --git a/packages/dev/materials/src/lava/lavaMaterial.ts b/packages/dev/materials/src/lava/lavaMaterial.ts index 10f387a1002d..ff5ce31f637c 100644 --- a/packages/dev/materials/src/lava/lavaMaterial.ts +++ b/packages/dev/materials/src/lava/lavaMaterial.ts @@ -210,7 +210,7 @@ export class LavaMaterial extends PushMaterial { } // Misc. - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); // Lights defines._needNormals = true; diff --git a/packages/dev/materials/src/mix/mixMaterial.ts b/packages/dev/materials/src/mix/mixMaterial.ts index 78c3c627107b..01894d3700e2 100644 --- a/packages/dev/materials/src/mix/mixMaterial.ts +++ b/packages/dev/materials/src/mix/mixMaterial.ts @@ -240,7 +240,7 @@ export class MixMaterial extends PushMaterial { } // Misc. - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); // Lights defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting); diff --git a/packages/dev/materials/src/normal/normalMaterial.ts b/packages/dev/materials/src/normal/normalMaterial.ts index 78fc4bd29412..d2ffc1c7d1bc 100644 --- a/packages/dev/materials/src/normal/normalMaterial.ts +++ b/packages/dev/materials/src/normal/normalMaterial.ts @@ -184,7 +184,7 @@ export class NormalMaterial extends PushMaterial { } // Misc. - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); // Lights defines._needNormals = true; diff --git a/packages/dev/materials/src/shadowOnly/shadowOnlyMaterial.ts b/packages/dev/materials/src/shadowOnly/shadowOnlyMaterial.ts index 3c7f4afee8ca..712d29dd4c37 100644 --- a/packages/dev/materials/src/shadowOnly/shadowOnlyMaterial.ts +++ b/packages/dev/materials/src/shadowOnly/shadowOnlyMaterial.ts @@ -141,7 +141,7 @@ export class ShadowOnlyMaterial extends PushMaterial { PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false); - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, 1); diff --git a/packages/dev/materials/src/simple/simpleMaterial.ts b/packages/dev/materials/src/simple/simpleMaterial.ts index 168ee233fb6c..49c4b7684140 100644 --- a/packages/dev/materials/src/simple/simpleMaterial.ts +++ b/packages/dev/materials/src/simple/simpleMaterial.ts @@ -141,7 +141,7 @@ export class SimpleMaterial extends PushMaterial { } // Misc. - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); // Lights defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting); diff --git a/packages/dev/materials/src/terrain/terrainMaterial.ts b/packages/dev/materials/src/terrain/terrainMaterial.ts index 32511fb83824..988603f87733 100644 --- a/packages/dev/materials/src/terrain/terrainMaterial.ts +++ b/packages/dev/materials/src/terrain/terrainMaterial.ts @@ -203,7 +203,7 @@ export class TerrainMaterial extends PushMaterial { } // Misc. - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); // Lights defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting); diff --git a/packages/dev/materials/src/triPlanar/triPlanarMaterial.ts b/packages/dev/materials/src/triPlanar/triPlanarMaterial.ts index 86f2c2ec9698..b90717f06cde 100644 --- a/packages/dev/materials/src/triPlanar/triPlanarMaterial.ts +++ b/packages/dev/materials/src/triPlanar/triPlanarMaterial.ts @@ -205,7 +205,7 @@ export class TriPlanarMaterial extends PushMaterial { } // Misc. - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); // Lights defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting); diff --git a/packages/dev/materials/src/water/waterMaterial.ts b/packages/dev/materials/src/water/waterMaterial.ts index 3ebabdcbcd99..88d03c6a9a28 100644 --- a/packages/dev/materials/src/water/waterMaterial.ts +++ b/packages/dev/materials/src/water/waterMaterial.ts @@ -394,7 +394,7 @@ export class WaterMaterial extends PushMaterial { PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false); - PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines); + PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines); if (defines._areMiscDirty) { defines.FRESNELSEPARATE = this._fresnelSeparate;