Browse Source

Update mixMaterial.ts

David 6 years ago
parent
commit
fd1eecbb59
1 changed files with 23 additions and 20 deletions
  1. 23 20
      materialsLibrary/src/mix/mixMaterial.ts

+ 23 - 20
materialsLibrary/src/mix/mixMaterial.ts

@@ -170,27 +170,27 @@ export class MixMaterial extends PushMaterial {
         var engine = scene.getEngine();
 
         // Textures
-        if (scene.texturesEnabled) {            
+        if (scene.texturesEnabled) {
             if (this._mixTexture1 && !this._mixTexture1.isReady()) {
                 return false;
             }
-                    
+
             defines._needUVs = true;
-            
+
             if (this._mixTexture2) {
                 defines.MIXMAP2 = true;
             }
-            if (this._mixTexture2 && !this._mixTexture2.isReady()) { 
+            if (this._mixTexture2 && !this._mixTexture2.isReady()) {
                 return false;
-            }          
-            
-            if (MaterialFlags.DiffuseTextureEnabled) {                 
+            }
+
+            if (MaterialFlags.DiffuseTextureEnabled) {
                 if (!this._diffuseTexture1 || !this._diffuseTexture1.isReady()) {
                     return false;
                 }
-                
+
                 defines.DIFFUSE = true;
-                
+
                 if (!this._diffuseTexture2 || !this._diffuseTexture2.isReady()) {
                     return false;
                 }
@@ -199,18 +199,21 @@ export class MixMaterial extends PushMaterial {
                 }
                 if (!this._diffuseTexture4 || !this._diffuseTexture4.isReady()) {
                     return false;
-                }                
-                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;
+
+                if (this._mixTexture2 !== null) {
+                    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;
+                    }
                 }
             }
         }