Hi all. We use alpha-tested leaf cards with needDepthPrePass to cut foliage overdraw, and found that on StandardMaterial the depth prepass skips the alpha test when the material uses transparencyMode = Material.MATERIAL_ALPHATEST. The prepass writes the depth of the entire quad, so the transparent part of the card hides whatever is drawn behind it afterwards.
Playground: https://playground.babylonjs.com/#G5C5KQ#1 Toggle needDepthPrePass to see the hole appear and disappear. It reproduces on both WebGL2 and WebGPU.
Cause. With a non-null transparencyMode, StandardMaterial defines ALPHATEST_AFTERALLALPHACOMPUTATIONS, which moves the alpha test to the end of default.fragment. But #include<depthPrePass> sits near the top and returns early in the DEPTHPREPASS variant, so in that variant the test never runs. (Line numbers from the built 9.17.1 shaders: GLSL default.fragment 120 / 134 / 256–257, WGSL 111 / 124 / 246–247.) PBR is not affected, because its alpha test runs inside the albedo/opacity block before the prepass exit. StandardMaterial on the legacy path (diffuseTexture.hasAlpha without transparencyMode) is not affected either, because it tests early.
Possible fix. In the DEPTHPREPASS variant, run the alpha test before the early return. Minimal version, just before #include<depthPrePass>:
#if defined(DEPTHPREPASS) && defined(ALPHATEST) && defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
if (alpha < alphaCutOff) discard;
#endif
Caveat: at that point alpha includes the diffuse-texture alpha but not contributions applied later (for example an opacity texture), so a complete fix would compute alpha fully before the prepass exit. We’re working around it with a small material plugin that injects the test above at CUSTOM_FRAGMENT_UPDATE_ALPHA, and would be glad to open a PR if you tell us which shape you prefer.