Sfoglia il codice sorgente

Merge pull request #9405 from Popov72/fix-softtransparentshadow-globalalpha

Use mesh.visibility and material.alpha for global alpha value in soft transparent shadow rendering
David Catuhe 4 anni fa
parent
commit
e4f402d108

+ 2 - 0
dist/preview release/what's new.md

@@ -18,3 +18,5 @@
 - Fix an issue with keyboard control (re)attachment. ([#9411](https://github.com/BabylonJS/Babylon.js/issues/9411)) ([RaananW](https://github.com/RaananW))
 - Fix an issue with keyboard control (re)attachment. ([#9411](https://github.com/BabylonJS/Babylon.js/issues/9411)) ([RaananW](https://github.com/RaananW))
 
 
 ## Breaking changes
 ## Breaking changes
+
+- Use both `mesh.visibility` and `material.alpha` values to compute the global alpha value used by the soft transparent shadow rendering code. Formerly was only using `mesh.visibility` ([Popov72](https://github.com/Popov72))

+ 2 - 2
src/Lights/Shadows/shadowGenerator.ts

@@ -1110,7 +1110,7 @@ export class ShadowGenerator implements IShadowGenerator {
         if (this.isReady(subMesh, hardwareInstancedRendering, isTransparent)) {
         if (this.isReady(subMesh, hardwareInstancedRendering, isTransparent)) {
             subMesh._renderId = scene.getRenderId();
             subMesh._renderId = scene.getRenderId();
 
 
-            const shadowDepthWrapper = renderingMesh.material?.shadowDepthWrapper;
+            const shadowDepthWrapper = material.shadowDepthWrapper;
 
 
             let effect = shadowDepthWrapper?.getEffect(subMesh, this) ?? this._effect;
             let effect = shadowDepthWrapper?.getEffect(subMesh, this) ?? this._effect;
 
 
@@ -1134,7 +1134,7 @@ export class ShadowGenerator implements IShadowGenerator {
             }
             }
 
 
             if (isTransparent && this.enableSoftTransparentShadow) {
             if (isTransparent && this.enableSoftTransparentShadow) {
-                effect.setFloat("softTransparentShadowSM", effectiveMesh.visibility);
+                effect.setFloat("softTransparentShadowSM", effectiveMesh.visibility * material.alpha);
             }
             }
 
 
             if (shadowDepthWrapper) {
             if (shadowDepthWrapper) {