浏览代码

Fixed `MixMaterial.isReadyForSubMesh` to remove WebGL warnings

Hi,
I took over this PR which corrected the TerrainMaterial and had the same problem with MixMaterial.
So I copy the patches on MixMaterial hoping it's good for you @julien-moreau 

https://github.com/BabylonJS/Babylon.js/commit/1a29f504d33f5031b4ec3aae90fadfd67c814e91
David 6 年之前
父节点
当前提交
0b9a2d868e
共有 1 个文件被更改,包括 42 次插入16 次删除
  1. 42 16
      materialsLibrary/src/mix/mixMaterial.ts

+ 42 - 16
materialsLibrary/src/mix/mixMaterial.ts

@@ -170,25 +170,51 @@ export class MixMaterial extends PushMaterial {
         var engine = scene.getEngine();
 
         // Textures
-        if (scene.texturesEnabled) {
-            if (MaterialFlags.DiffuseTextureEnabled) {
-                if (this._mixTexture1) {
-                    if (!this._mixTexture1.isReady()) {
-                        return false;
-                    } else {
-                        defines._needUVs = true;
-                        defines.DIFFUSE = true;
-                    }
+        if (scene.texturesEnabled) {            
+            if (!this._mixTexture1 || !this._mixTexture1.isReady()) {
+                return false;
+            }
+                    
+            defines._needUVs = true;
+            
+            if (!this._mixTexture2 || !this._mixTexture2.isReady()) {                   
+                return false;
+            } else {                    
+                defines.MIXMAP2 = true;
+            }
+            
+            if (MaterialFlags.DiffuseTextureEnabled) { 
+                if (!this._diffuseTexture1 || !this._diffuseTexture1.isReady()) {
+                    return false;
                 }
-                if (this._mixTexture2) {
-                    if (!this._mixTexture2.isReady()) {
-                        return false;
-                    } else {
-                        defines.MIXMAP2 = true;
-                    }
+                if (!this._diffuseTexture2 || !this._diffuseTexture2.isReady()) {
+                    return false;
+                }
+                if (!this._diffuseTexture3 || !this._diffuseTexture3.isReady()) {
+                    return false;
+                }
+                if (!this._diffuseTexture4 || !this._diffuseTexture4.isReady()) {
+                    return false;
+                }  
+                
+                defines.DIFFUSE = true;
+                
+                if (!this._diffuseTexture5 || !this._diffuseTexture5.isReady()) {
+                    return false;
+                }
+                if (!this._diffuseTexture6 || !this._diffuseTexture6.isReady()) {
+                    return false;
+                }
+                if (!this._diffuseTexture7 || !this._diffuseTexture7.isReady()) {
+                    return false;
                 }
+                if (!this._diffuseTexture8 || !this._diffuseTexture8.isReady()) {
+                    return false;
+                }          
+                                 
             }
         }
+       
 
         // Misc.
         MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
@@ -535,4 +561,4 @@ export class MixMaterial extends PushMaterial {
     }
 }
 
-_TypeStore.RegisteredTypes["BABYLON.MixMaterial"] = MixMaterial;
+_TypeStore.RegisteredTypes["BABYLON.MixMaterial"] = MixMaterial;