Explorar o código

shadow on transparent meshes

Clément Levasseur %!s(int64=11) %!d(string=hai) anos
pai
achega
0f62fedca7
Modificáronse 1 ficheiros con 14 adicións e 1 borrados
  1. 14 1
      Babylon/Lights/Shadows/babylon.shadowGenerator.js

+ 14 - 1
Babylon/Lights/Shadows/babylon.shadowGenerator.js

@@ -17,6 +17,9 @@ var BABYLON = BABYLON || {};
 
         // Darkness
         this._darkness = 0.;
+
+        // Darkness
+        this._transparencyShadow = false;        
                 
         // Custom render function
         var that = this;
@@ -45,7 +48,7 @@ var BABYLON = BABYLON || {};
             }
         };
 
-        this._shadowMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes) {
+        this._shadowMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes) {
             var index;
             
             for (index = 0; index < opaqueSubMeshes.length; index++) {
@@ -55,6 +58,12 @@ var BABYLON = BABYLON || {};
             for (index = 0; index < alphaTestSubMeshes.length; index++) {
                 renderSubMesh(alphaTestSubMeshes.data[index]);
             }
+
+            if (that._transparencyShadow) {
+                for (index = 0; index < transparentSubMeshes.length; index++) {
+                    renderSubMesh(transparentSubMeshes.data[index]);
+                }                
+            }
         };
         
         // Internals
@@ -142,6 +151,10 @@ var BABYLON = BABYLON || {};
             this._darkness = darkness;
     };
 
+    BABYLON.ShadowGenerator.prototype.setTransparencyShadow = function (hasShadow) {
+        this._transparencyShadow = hasShadow;
+    };
+
     BABYLON.ShadowGenerator.prototype.dispose = function() {
         this._shadowMap.dispose();
     };