ソースを参照

New 3dsmax exporter with debug layer integrated

David Catuhe 10 年 前
コミット
70e2d68f2c
31 ファイル変更604 行追加370 行削除
  1. 6 2
      Babylon/Loading/Plugins/babylon.babylonFileLoader.js
  2. 6 2
      Babylon/Loading/Plugins/babylon.babylonFileLoader.ts
  3. 13 14
      Babylon/Materials/babylon.effect.js
  4. 20 21
      Babylon/Materials/babylon.effect.ts
  5. 21 4
      Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.js
  6. 23 5
      Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.ts
  7. 15 36
      Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.js
  8. 85 98
      Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.ts
  9. 1 1
      Babylon/Materials/textures/babylon.baseTexture.js
  10. 7 7
      Babylon/Materials/textures/babylon.baseTexture.ts
  11. 1 1
      Babylon/Mesh/babylon.abstractMesh.js
  12. 1 1
      Babylon/Mesh/babylon.abstractMesh.ts
  13. 1 1
      Babylon/Mesh/babylon.subMesh.ts
  14. 5 7
      Babylon/Rendering/babylon.renderingGroup.js
  15. 6 8
      Babylon/Rendering/babylon.renderingGroup.ts
  16. 5 5
      Babylon/Shaders/brick.fragment.fx
  17. 3 3
      Babylon/Shaders/fire.fragment.fx
  18. 8 9
      Babylon/Shaders/grass.fragment.fx
  19. 9 9
      Babylon/Shaders/marble.fragment.fx
  20. 6 0
      Exporters/3ds Max/BabylonExport.Entities/BabylonMesh.cs
  21. BIN
      Exporters/3ds Max/Max2Babylon-0.8.3.zip
  22. BIN
      Exporters/3ds Max/Max2Babylon-0.8.5.zip
  23. 11 2
      Exporters/3ds Max/Max2Babylon/Exporter/BabylonExporter.Camera.cs
  24. 2 0
      Exporters/3ds Max/Max2Babylon/Exporter/BabylonExporter.Mesh.cs
  25. 19 10
      Exporters/3ds Max/Max2Babylon/Exporter/BabylonExporter.cs
  26. 34 5
      Exporters/3ds Max/Max2Babylon/Forms/ObjectPropertiesForm.Designer.cs
  27. 3 0
      Exporters/3ds Max/Max2Babylon/Forms/ObjectPropertiesForm.cs
  28. 69 0
      Exporters/3ds Max/Max2Babylon/Tools/Tools.cs
  29. 21 1
      Exporters/3ds Max/Max2Babylon/Tools/WebServer.cs
  30. 195 110
      babylon.2.0-alpha.debug.js
  31. 8 8
      babylon.2.0-alpha.js

+ 6 - 2
Babylon/Loading/Plugins/babylon.babylonFileLoader.js

@@ -647,14 +647,18 @@
             mesh.showBoundingBox = parsedMesh.showBoundingBox;
             mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
 
-            if (parseMesh.applyFog !== undefined) {
-                mesh.applyFog = parseMesh.applyFog;
+            if (parsedMesh.applyFog !== undefined) {
+                mesh.applyFog = parsedMesh.applyFog;
             }
 
             if (parsedMesh.pickable !== undefined) {
                 mesh.isPickable = parsedMesh.pickable;
             }
 
+            if (parsedMesh.alphaIndex !== undefined) {
+                mesh.alphaIndex = parsedMesh.alphaIndex;
+            }
+
             mesh.receiveShadows = parsedMesh.receiveShadows;
 
             mesh.billboardMode = parsedMesh.billboardMode;

+ 6 - 2
Babylon/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -656,14 +656,18 @@
         mesh.showBoundingBox = parsedMesh.showBoundingBox;
         mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
 
-        if (parseMesh.applyFog !== undefined) {
-            mesh.applyFog = parseMesh.applyFog;
+        if (parsedMesh.applyFog !== undefined) {
+            mesh.applyFog = parsedMesh.applyFog;
         }
 
         if (parsedMesh.pickable !== undefined) {
             mesh.isPickable = parsedMesh.pickable;
         }
 
+        if (parsedMesh.alphaIndex !== undefined) {
+            mesh.alphaIndex = parsedMesh.alphaIndex;
+        }
+
         mesh.receiveShadows = parsedMesh.receiveShadows;
 
         mesh.billboardMode = parsedMesh.billboardMode;

+ 13 - 14
Babylon/Materials/babylon.effect.js

@@ -143,8 +143,8 @@
             }
 
             // Is in local store ?
-            if (BABYLON.Effect.ShadersStore[vertex + "VertexShader"]) {
-                callback(BABYLON.Effect.ShadersStore[vertex + "VertexShader"]);
+            if (Effect.ShadersStore[vertex + "VertexShader"]) {
+                callback(Effect.ShadersStore[vertex + "VertexShader"]);
                 return;
             }
 
@@ -169,13 +169,13 @@
             }
 
             // Is in local store ?
-            if (BABYLON.Effect.ShadersStore[fragment + "PixelShader"]) {
-                callback(BABYLON.Effect.ShadersStore[fragment + "PixelShader"]);
+            if (Effect.ShadersStore[fragment + "PixelShader"]) {
+                callback(Effect.ShadersStore[fragment + "PixelShader"]);
                 return;
             }
 
-            if (BABYLON.Effect.ShadersStore[fragment + "FragmentShader"]) {
-                callback(BABYLON.Effect.ShadersStore[fragment + "FragmentShader"]);
+            if (Effect.ShadersStore[fragment + "FragmentShader"]) {
+                callback(Effect.ShadersStore[fragment + "FragmentShader"]);
                 return;
             }
 
@@ -208,7 +208,6 @@
                         index--;
                     }
                 }
-
                 engine.bindSamplers(this);
 
                 this._isReady = true;
@@ -340,7 +339,7 @@
         };
 
         Effect.prototype.setVector2 = function (uniformName, vector2) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == vector2.x && this._valueCache[uniformName][1] == vector2.y)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === vector2.x && this._valueCache[uniformName][1] === vector2.y)
                 return this;
 
             this._cacheFloat2(uniformName, vector2.x, vector2.y);
@@ -350,7 +349,7 @@
         };
 
         Effect.prototype.setFloat2 = function (uniformName, x, y) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == x && this._valueCache[uniformName][1] == y)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y)
                 return this;
 
             this._cacheFloat2(uniformName, x, y);
@@ -360,7 +359,7 @@
         };
 
         Effect.prototype.setVector3 = function (uniformName, vector3) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == vector3.x && this._valueCache[uniformName][1] == vector3.y && this._valueCache[uniformName][2] == vector3.z)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === vector3.x && this._valueCache[uniformName][1] === vector3.y && this._valueCache[uniformName][2] === vector3.z)
                 return this;
 
             this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z);
@@ -371,7 +370,7 @@
         };
 
         Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == x && this._valueCache[uniformName][1] == y && this._valueCache[uniformName][2] == z)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y && this._valueCache[uniformName][2] === z)
                 return this;
 
             this._cacheFloat3(uniformName, x, y, z);
@@ -381,7 +380,7 @@
         };
 
         Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == x && this._valueCache[uniformName][1] == y && this._valueCache[uniformName][2] == z && this._valueCache[uniformName][3] == w)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y && this._valueCache[uniformName][2] === z && this._valueCache[uniformName][3] === w)
                 return this;
 
             this._cacheFloat4(uniformName, x, y, z, w);
@@ -391,7 +390,7 @@
         };
 
         Effect.prototype.setColor3 = function (uniformName, color3) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == color3.r && this._valueCache[uniformName][1] == color3.g && this._valueCache[uniformName][2] == color3.b)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === color3.r && this._valueCache[uniformName][1] === color3.g && this._valueCache[uniformName][2] === color3.b)
                 return this;
 
             this._cacheFloat3(uniformName, color3.r, color3.g, color3.b);
@@ -401,7 +400,7 @@
         };
 
         Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == color3.r && this._valueCache[uniformName][1] == color3.g && this._valueCache[uniformName][2] == color3.b && this._valueCache[uniformName][3] == alpha)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === color3.r && this._valueCache[uniformName][1] === color3.g && this._valueCache[uniformName][2] === color3.b && this._valueCache[uniformName][3] === alpha)
                 return this;
 
             this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha);

+ 20 - 21
Babylon/Materials/babylon.effect.ts

@@ -147,14 +147,14 @@
         public _loadVertexShader(vertex: any, callback: (data: any) => void): void {
             // DOM element ?
             if (vertex instanceof HTMLElement) {
-                var vertexCode = BABYLON.Tools.GetDOMTextContent(vertex);
+                var vertexCode = Tools.GetDOMTextContent(vertex);
                 callback(vertexCode);
                 return;
             }
 
             // Is in local store ?
-            if (BABYLON.Effect.ShadersStore[vertex + "VertexShader"]) {
-                callback(BABYLON.Effect.ShadersStore[vertex + "VertexShader"]);
+            if (Effect.ShadersStore[vertex + "VertexShader"]) {
+                callback(Effect.ShadersStore[vertex + "VertexShader"]);
                 return;
             }
 
@@ -163,29 +163,29 @@
             if (vertex[0] === ".") {
                 vertexShaderUrl = vertex;
             } else {
-                vertexShaderUrl = BABYLON.Engine.ShadersRepository + vertex;
+                vertexShaderUrl = Engine.ShadersRepository + vertex;
             }
 
             // Vertex shader
-            BABYLON.Tools.LoadFile(vertexShaderUrl + ".vertex.fx", callback);
+            Tools.LoadFile(vertexShaderUrl + ".vertex.fx", callback);
         }
 
         public _loadFragmentShader(fragment: any, callback: (data: any) => void): void {
             // DOM element ?
             if (fragment instanceof HTMLElement) {
-                var fragmentCode = BABYLON.Tools.GetDOMTextContent(fragment);
+                var fragmentCode = Tools.GetDOMTextContent(fragment);
                 callback(fragmentCode);
                 return;
             }
 
             // Is in local store ?
-            if (BABYLON.Effect.ShadersStore[fragment + "PixelShader"]) {
-                callback(BABYLON.Effect.ShadersStore[fragment + "PixelShader"]);
+            if (Effect.ShadersStore[fragment + "PixelShader"]) {
+                callback(Effect.ShadersStore[fragment + "PixelShader"]);
                 return;
             }
 
-            if (BABYLON.Effect.ShadersStore[fragment + "FragmentShader"]) {
-                callback(BABYLON.Effect.ShadersStore[fragment + "FragmentShader"]);
+            if (Effect.ShadersStore[fragment + "FragmentShader"]) {
+                callback(Effect.ShadersStore[fragment + "FragmentShader"]);
                 return;
             }
 
@@ -194,11 +194,11 @@
             if (fragment[0] === ".") {
                 fragmentShaderUrl = fragment;
             } else {
-                fragmentShaderUrl = BABYLON.Engine.ShadersRepository + fragment;
+                fragmentShaderUrl = Engine.ShadersRepository + fragment;
             }
 
             // Fragment shader
-            BABYLON.Tools.LoadFile(fragmentShaderUrl + ".fragment.fx", callback);
+            Tools.LoadFile(fragmentShaderUrl + ".fragment.fx", callback);
         }
 
         private _prepareEffect(vertexSourceCode: string, fragmentSourceCode: string, attributesNames: string[], defines: string, fallbacks?: EffectFallbacks): void {
@@ -218,7 +218,6 @@
                         index--;
                     }
                 }
-
                 engine.bindSamplers(this);
 
                 this._isReady = true;
@@ -239,7 +238,7 @@
                 if (fallbacks && fallbacks.isMoreFallbacks) {
                     defines = fallbacks.reduce(defines);
                     this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks);
-                } else { // SOrry we did everything we can
+                } else { // Sorry we did everything we can
                     Tools.Error("Unable to compile effect: " + this.name);
                     Tools.Error("Defines: " + defines);
                     Tools.Error("Error: " + e.message);
@@ -352,7 +351,7 @@
         }
 
         public setVector2(uniformName: string, vector2: Vector2): Effect {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == vector2.x && this._valueCache[uniformName][1] == vector2.y)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === vector2.x && this._valueCache[uniformName][1] === vector2.y)
                 return this;
 
             this._cacheFloat2(uniformName, vector2.x, vector2.y);
@@ -362,7 +361,7 @@
         }
 
         public setFloat2(uniformName: string, x: number, y: number): Effect {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == x && this._valueCache[uniformName][1] == y)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y)
                 return this;
 
             this._cacheFloat2(uniformName, x, y);
@@ -372,7 +371,7 @@
         }
 
         public setVector3(uniformName: string, vector3: Vector3): Effect {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == vector3.x && this._valueCache[uniformName][1] == vector3.y && this._valueCache[uniformName][2] == vector3.z)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === vector3.x && this._valueCache[uniformName][1] === vector3.y && this._valueCache[uniformName][2] === vector3.z)
                 return this;
 
             this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z);
@@ -383,7 +382,7 @@
         }
 
         public setFloat3(uniformName: string, x: number, y: number, z: number): Effect {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == x && this._valueCache[uniformName][1] == y && this._valueCache[uniformName][2] == z)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y && this._valueCache[uniformName][2] === z)
                 return this;
 
             this._cacheFloat3(uniformName, x, y, z);
@@ -393,7 +392,7 @@
         }
 
         public setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == x && this._valueCache[uniformName][1] == y && this._valueCache[uniformName][2] == z && this._valueCache[uniformName][3] == w)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y && this._valueCache[uniformName][2] === z && this._valueCache[uniformName][3] === w)
                 return this;
 
             this._cacheFloat4(uniformName, x, y, z, w);
@@ -403,7 +402,7 @@
         }
 
         public setColor3(uniformName: string, color3: Color3): Effect {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == color3.r && this._valueCache[uniformName][1] == color3.g && this._valueCache[uniformName][2] == color3.b)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === color3.r && this._valueCache[uniformName][1] === color3.g && this._valueCache[uniformName][2] === color3.b)
                 return this;
 
             this._cacheFloat3(uniformName, color3.r, color3.g, color3.b);
@@ -413,7 +412,7 @@
         }
 
         public setColor4(uniformName: string, color3: Color3, alpha: number): Effect {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == color3.r && this._valueCache[uniformName][1] == color3.g && this._valueCache[uniformName][2] == color3.b && this._valueCache[uniformName][3] == alpha)
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === color3.r && this._valueCache[uniformName][1] === color3.g && this._valueCache[uniformName][2] === color3.b && this._valueCache[uniformName][3] === alpha)
                 return this;
 
             this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha);

+ 21 - 4
Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.js

@@ -25,6 +25,7 @@ var BABYLON;
             this._vectors2 = new Array();
             this._vectors3 = new Array();
             this._matrices = new Array();
+            this._fallbackTextureUsed = false;
 
             scene._proceduralTextures.push(this);
 
@@ -77,6 +78,10 @@ var BABYLON;
                 return false;
             }
 
+            if (this._fallbackTextureUsed) {
+                return true;
+            }
+
             if (this._fragment.fragmentElement !== undefined) {
                 shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
             } else {
@@ -86,8 +91,12 @@ var BABYLON;
             this._effect = engine.createEffect(shaders, ["position"], this._uniforms, this._samplers, "", null, null, function () {
                 _this.releaseInternalTexture();
 
-                _this._texture = _this._fallbackTexture._texture;
-                _this._texture.references++;
+                if (_this._fallbackTexture) {
+                    _this._texture = _this._fallbackTexture._texture;
+                    _this._texture.references++;
+                }
+
+                _this._fallbackTextureUsed = true;
             });
 
             return this._effect.isReady();
@@ -120,12 +129,16 @@ var BABYLON;
                 return false;
             }
 
+            if (this._fallbackTextureUsed) {
+                return false;
+            }
+
             if (this._currentRefreshId === -1) {
                 this._currentRefreshId = 1;
                 return true;
             }
 
-            if (this.refreshRate == this._currentRefreshId) {
+            if (this.refreshRate === this._currentRefreshId) {
                 this._currentRefreshId = 1;
                 return true;
             }
@@ -139,6 +152,10 @@ var BABYLON;
         };
 
         ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
+            if (this._fallbackTextureUsed) {
+                return;
+            }
+
             this.releaseInternalTexture();
             this._texture = this.getScene().getEngine().createRenderTargetTexture(size, generateMipMaps);
         };
@@ -265,7 +282,7 @@ var BABYLON;
 
         ProceduralTexture.prototype.clone = function () {
             var textureSize = this.getSize();
-            var newTexture = new BABYLON.ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
+            var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
 
             // Base texture
             newTexture.hasAlpha = this.hasAlpha;

+ 23 - 5
Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.ts

@@ -28,6 +28,8 @@
 
         private _fallbackTexture: Texture;
 
+        private _fallbackTextureUsed = false;
+
         constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Texture, generateMipMaps = true) {
             super(null, scene, !generateMipMaps);
 
@@ -74,7 +76,7 @@
             engine._releaseEffect(this._effect);
         }
 
-      
+
         public isReady(): boolean {
             var engine = this.getScene().getEngine();
             var shaders;
@@ -83,6 +85,10 @@
                 return false;
             }
 
+            if (this._fallbackTextureUsed) {
+                return true;
+            }
+
             if (this._fragment.fragmentElement !== undefined) {
                 shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
             }
@@ -97,8 +103,12 @@
                 "", null, null, () => {
                     this.releaseInternalTexture();
 
-                    this._texture = this._fallbackTexture._texture;
-                    this._texture.references++;
+                    if (this._fallbackTexture) {
+                        this._texture = this._fallbackTexture._texture;
+                        this._texture.references++;
+                    }
+
+                    this._fallbackTextureUsed = true;
                 });
 
             return this._effect.isReady();
@@ -127,12 +137,16 @@
                 return false;
             }
 
+            if (this._fallbackTextureUsed) {
+                return false;
+            }
+
             if (this._currentRefreshId === -1) { // At least render once
                 this._currentRefreshId = 1;
                 return true;
             }
 
-            if (this.refreshRate == this._currentRefreshId) {
+            if (this.refreshRate === this._currentRefreshId) {
                 this._currentRefreshId = 1;
                 return true;
             }
@@ -146,6 +160,10 @@
         }
 
         public resize(size, generateMipMaps) {
+            if (this._fallbackTextureUsed) {
+                return;
+            }
+
             this.releaseInternalTexture();
             this._texture = this.getScene().getEngine().createRenderTargetTexture(size, generateMipMaps);
         }
@@ -280,7 +298,7 @@
 
         public clone(): ProceduralTexture {
             var textureSize = this.getSize();
-            var newTexture = new BABYLON.ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
+            var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
 
             // Base texture
             newTexture.hasAlpha = this.hasAlpha;

+ 15 - 36
Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.js

@@ -56,7 +56,6 @@ var BABYLON;
             this._time = 0.0;
             this._speed = new BABYLON.Vector2(0.5, 0.3);
             this._shift = 1.6;
-            this._alpha = 0.0;
             this._autoGenerateTime = true;
             this._alphaThreshold = 0.5;
             this._fireColors = FireProceduralTexture.RedFireColors;
@@ -64,10 +63,9 @@ var BABYLON;
             this.refreshRate = 1;
         }
         FireProceduralTexture.prototype.updateShaderUniforms = function () {
-            this.setFloat("iGlobalTime", this._time);
+            this.setFloat("time", this._time);
             this.setVector2("speed", this._speed);
             this.setFloat("shift", this._shift);
-            this.setFloat("alpha", this._alpha);
             this.setColor3("c1", this._fireColors[0]);
             this.setColor3("c2", this._fireColors[1]);
             this.setColor3("c3", this._fireColors[2]);
@@ -197,12 +195,12 @@ var BABYLON;
         });
 
 
-        Object.defineProperty(FireProceduralTexture.prototype, "alpha", {
+        Object.defineProperty(FireProceduralTexture.prototype, "alphaThreshold", {
             get: function () {
-                return this._alpha;
+                return this._alphaThreshold;
             },
             set: function (value) {
-                this._alpha = value;
+                this._alphaThreshold = value;
                 this.updateShaderUniforms();
             },
             enumerable: true,
@@ -263,7 +261,6 @@ var BABYLON;
             this._herb1 = new BABYLON.Color3(0.29, 0.38, 0.02);
             this._herb2 = new BABYLON.Color3(0.36, 0.49, 0.09);
             this._herb3 = new BABYLON.Color3(0.51, 0.6, 0.28);
-            this._dirtColor = new BABYLON.Color3(0.6, 0.46, 0.13);
             this._groundColor = new BABYLON.Color3(1, 1, 1);
 
             this._grassColors = [
@@ -276,11 +273,10 @@ var BABYLON;
             this.refreshRate = 0;
         }
         GrassProceduralTexture.prototype.updateShaderUniforms = function () {
-            this.setColor3("herb1", this._grassColors[0]);
-            this.setColor3("herb2", this._grassColors[1]);
-            this.setColor3("herb3", this._grassColors[2]);
-            this.setColor3("dirt", this._dirtColor);
-            this.setColor3("ground", this._groundColor);
+            this.setColor3("herb1Color", this._grassColors[0]);
+            this.setColor3("herb2Color", this._grassColors[1]);
+            this.setColor3("herb3Color", this._grassColors[2]);
+            this.setColor3("groundColor", this._groundColor);
         };
 
         Object.defineProperty(GrassProceduralTexture.prototype, "grassColors", {
@@ -296,28 +292,10 @@ var BABYLON;
         });
 
 
-        Object.defineProperty(GrassProceduralTexture.prototype, "dirtColor", {
-            get: function () {
-                return this._dirtColor;
-            },
-            set: function (value) {
-                this._dirtColor = value;
-                this.updateShaderUniforms();
-            },
-            enumerable: true,
-            configurable: true
-        });
-
-
         Object.defineProperty(GrassProceduralTexture.prototype, "groundColor", {
             get: function () {
                 return this._groundColor;
             },
-            enumerable: true,
-            configurable: true
-        });
-
-        Object.defineProperty(GrassProceduralTexture.prototype, "ground", {
             set: function (value) {
                 this.groundColor = value;
                 this.updateShaderUniforms();
@@ -325,6 +303,7 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+
         return GrassProceduralTexture;
     })(BABYLON.ProceduralTexture);
     BABYLON.GrassProceduralTexture = GrassProceduralTexture;
@@ -371,8 +350,8 @@ var BABYLON;
         BrickProceduralTexture.prototype.updateShaderUniforms = function () {
             this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
             this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
-            this.setColor3("brick", this._brickColor);
-            this.setColor3("joint", this._jointColor);
+            this.setColor3("brickColor", this._brickColor);
+            this.setColor3("jointColor", this._jointColor);
         };
 
         Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksHeight", {
@@ -447,11 +426,11 @@ var BABYLON;
             this.refreshRate = 0;
         }
         MarbleProceduralTexture.prototype.updateShaderUniforms = function () {
-            this.setFloat("numberOfBricksHeight", this._numberOfTilesHeight);
-            this.setFloat("numberOfBricksWidth", this._numberOfTilesWidth);
+            this.setFloat("numberOfTilesHeight", this._numberOfTilesHeight);
+            this.setFloat("numberOfTilesWidth", this._numberOfTilesWidth);
             this.setFloat("amplitude", this._amplitude);
-            this.setColor3("brick", this._marbleColor);
-            this.setColor3("joint", this._jointColor);
+            this.setColor3("marbleColor", this._marbleColor);
+            this.setColor3("jointColor", this._jointColor);
         };
 
         Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesHeight", {

+ 85 - 98
Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.ts

@@ -1,7 +1,7 @@
 module BABYLON {
     export class WoodProceduralTexture extends ProceduralTexture {
         private _ampScale: number = 100.0;
-        private _woodColor: BABYLON.Color3 = new BABYLON.Color3(0.32, 0.17, 0.09);
+        private _woodColor: Color3 = new Color3(0.32, 0.17, 0.09);
 
         constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
             super(name, size, "wood", scene, fallbackTexture, generateMipMaps);
@@ -23,11 +23,11 @@
             this.updateShaderUniforms();
         }
 
-        public get woodColor(): BABYLON.Color3 {
+        public get woodColor(): Color3 {
             return this._woodColor;
         }
 
-        public set woodColor(value: BABYLON.Color3) {
+        public set woodColor(value: Color3) {
             this._woodColor = value;
             this.updateShaderUniforms();
         }
@@ -35,11 +35,10 @@
 
     export class FireProceduralTexture extends ProceduralTexture {
         private _time: number = 0.0;
-        private _speed: BABYLON.Vector2 = new BABYLON.Vector2(0.5, 0.3);
+        private _speed = new Vector2(0.5, 0.3);
         private _shift: number = 1.6;
-        private _alpha: number = 0.0;
         private _autoGenerateTime: boolean = true;
-        private _fireColors: BABYLON.Color3[];
+        private _fireColors: Color3[];
         private _alphaThreshold: number = 0.5;
 
         constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
@@ -50,10 +49,9 @@
         }
 
         public updateShaderUniforms() {
-            this.setFloat("iGlobalTime", this._time);
+            this.setFloat("time", this._time);
             this.setVector2("speed", this._speed);
             this.setFloat("shift", this._shift);
-            this.setFloat("alpha", this._alpha);
             this.setColor3("c1", this._fireColors[0]);
             this.setColor3("c2", this._fireColors[1]);
             this.setColor3("c3", this._fireColors[2]);
@@ -71,55 +69,55 @@
             super.render(useCameraPostProcess);
         }
 
-        public static get PurpleFireColors(): BABYLON.Color3[] {
+        public static get PurpleFireColors(): Color3[] {
             return [
-                new BABYLON.Color3(0.5, 0.0, 1.0),
-                new BABYLON.Color3(0.9, 0.0, 1.0),
-                new BABYLON.Color3(0.2, 0.0, 1.0),
-                new BABYLON.Color3(1.0, 0.9, 1.0),
-                new BABYLON.Color3(0.1, 0.1, 1.0),
-                new BABYLON.Color3(0.9, 0.9, 1.0)
+                new Color3(0.5, 0.0, 1.0),
+                new Color3(0.9, 0.0, 1.0),
+                new Color3(0.2, 0.0, 1.0),
+                new Color3(1.0, 0.9, 1.0),
+                new Color3(0.1, 0.1, 1.0),
+                new Color3(0.9, 0.9, 1.0)
             ];
         }
 
-        public static get GreenFireColors(): BABYLON.Color3[] {
+        public static get GreenFireColors(): Color3[] {
             return [
-                new BABYLON.Color3(0.5, 1.0, 0.0),
-                new BABYLON.Color3(0.5, 1.0, 0.0),
-                new BABYLON.Color3(0.3, 0.4, 0.0),
-                new BABYLON.Color3(0.5, 1.0, 0.0),
-                new BABYLON.Color3(0.2, 0.0, 0.0),
-                new BABYLON.Color3(0.5, 1.0, 0.0)
+                new Color3(0.5, 1.0, 0.0),
+                new Color3(0.5, 1.0, 0.0),
+                new Color3(0.3, 0.4, 0.0),
+                new Color3(0.5, 1.0, 0.0),
+                new Color3(0.2, 0.0, 0.0),
+                new Color3(0.5, 1.0, 0.0)
             ];
         }
 
-        public static get RedFireColors(): BABYLON.Color3[] {
+        public static get RedFireColors(): Color3[] {
             return [
-                new BABYLON.Color3(0.5, 0.0, 0.1),
-                new BABYLON.Color3(0.9, 0.0, 0.0),
-                new BABYLON.Color3(0.2, 0.0, 0.0),
-                new BABYLON.Color3(1.0, 0.9, 0.0),
-                new BABYLON.Color3(0.1, 0.1, 0.1),
-                new BABYLON.Color3(0.9, 0.9, 0.9)
+                new Color3(0.5, 0.0, 0.1),
+                new Color3(0.9, 0.0, 0.0),
+                new Color3(0.2, 0.0, 0.0),
+                new Color3(1.0, 0.9, 0.0),
+                new Color3(0.1, 0.1, 0.1),
+                new Color3(0.9, 0.9, 0.9)
             ];
         }
 
-        public static get BlueFireColors(): BABYLON.Color3[] {
+        public static get BlueFireColors(): Color3[] {
             return [
-                new BABYLON.Color3(0.1, 0.0, 0.5),
-                new BABYLON.Color3(0.0, 0.0, 0.5),
-                new BABYLON.Color3(0.1, 0.0, 0.2),
-                new BABYLON.Color3(0.0, 0.0, 1.0),
-                new BABYLON.Color3(0.1, 0.2, 0.3),
-                new BABYLON.Color3(0.0, 0.2, 0.9)
+                new Color3(0.1, 0.0, 0.5),
+                new Color3(0.0, 0.0, 0.5),
+                new Color3(0.1, 0.0, 0.2),
+                new Color3(0.0, 0.0, 1.0),
+                new Color3(0.1, 0.2, 0.3),
+                new Color3(0.0, 0.2, 0.9)
             ];
         }
 
-        public get fireColors(): BABYLON.Color3[] {
+        public get fireColors(): Color3[] {
             return this._fireColors;
         }
 
-        public set fireColors(value: BABYLON.Color3[]) {
+        public set fireColors(value: Color3[]) {
             this._fireColors = value;
             this.updateShaderUniforms();
         }
@@ -133,11 +131,11 @@
             this.updateShaderUniforms();
         }
 
-        public get speed(): BABYLON.Vector2 {
+        public get speed(): Vector2 {
             return this._speed;
         }
 
-        public set speed(value: BABYLON.Vector2) {
+        public set speed(value: Vector2) {
             this._speed = value;
             this.updateShaderUniforms();
         }
@@ -151,19 +149,19 @@
             this.updateShaderUniforms();
         }
 
-        public get alpha(): number {
-            return this._alpha;
+        public get alphaThreshold(): number {
+            return this._alphaThreshold;
         }
 
-        public set alpha(value: number) {
-            this._alpha = value;
+        public set alphaThreshold(value: number) {
+            this._alphaThreshold = value;
             this.updateShaderUniforms();
         }
     }
 
     export class CloudProceduralTexture extends ProceduralTexture {
-        private _skyColor: BABYLON.Color3 = new BABYLON.Color3(0.15, 0.68, 1.0);
-        private _cloudColor: BABYLON.Color3 = new BABYLON.Color3(1, 1, 1);
+        private _skyColor = new Color3(0.15, 0.68, 1.0);
+        private _cloudColor = new Color3(1, 1, 1);
 
         constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
             super(name, size, "cloud", scene, fallbackTexture, generateMipMaps);
@@ -176,40 +174,39 @@
             this.setColor3("cloudColor", this._cloudColor);
         }
 
-        public get skyColor(): BABYLON.Color3 {
+        public get skyColor(): Color3 {
             return this._skyColor;
         }
 
-        public set skyColor(value: BABYLON.Color3) {
+        public set skyColor(value: Color3) {
             this._skyColor = value;
             this.updateShaderUniforms();
         }
 
-        public get cloudColor(): BABYLON.Color3 {
+        public get cloudColor(): Color3 {
             return this._cloudColor;
         }
 
-        public set cloudColor(value: BABYLON.Color3) {
+        public set cloudColor(value: Color3) {
             this._cloudColor = value;
             this.updateShaderUniforms();
         }
     }
 
     export class GrassProceduralTexture extends ProceduralTexture {
-        private _grassColors: BABYLON.Color3[];
-        private _herb1: BABYLON.Color3 = new BABYLON.Color3(0.29, 0.38, 0.02);
-        private _herb2: BABYLON.Color3 = new BABYLON.Color3(0.36, 0.49, 0.09);
-        private _herb3: BABYLON.Color3 = new BABYLON.Color3(0.51, 0.6, 0.28);
-        private _dirtColor: BABYLON.Color3 = new BABYLON.Color3(0.6, 0.46, 0.13);
-        private _groundColor: BABYLON.Color3 = new BABYLON.Color3(1, 1, 1);
+        private _grassColors: Color3[];
+        private _herb1 = new Color3(0.29, 0.38, 0.02);
+        private _herb2 = new Color3(0.36, 0.49, 0.09);
+        private _herb3 = new Color3(0.51, 0.6, 0.28);
+        private _groundColor = new Color3(1, 1, 1);
 
         constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
             super(name, size, "grass", scene, fallbackTexture, generateMipMaps);
 
             this._grassColors = [
-                new BABYLON.Color3(0.29, 0.38, 0.02),
-                new BABYLON.Color3(0.36, 0.49, 0.09),
-                new BABYLON.Color3(0.51, 0.6, 0.28),
+                new Color3(0.29, 0.38, 0.02),
+                new Color3(0.36, 0.49, 0.09),
+                new Color3(0.51, 0.6, 0.28)
             ];
 
             this.updateShaderUniforms();
@@ -217,43 +214,33 @@
         }
 
         public updateShaderUniforms() {
-            this.setColor3("herb1", this._grassColors[0]);
-            this.setColor3("herb2", this._grassColors[1]);
-            this.setColor3("herb3", this._grassColors[2]);
-            this.setColor3("dirt", this._dirtColor);
-            this.setColor3("ground", this._groundColor);
+            this.setColor3("herb1Color", this._grassColors[0]);
+            this.setColor3("herb2Color", this._grassColors[1]);
+            this.setColor3("herb3Color", this._grassColors[2]);
+            this.setColor3("groundColor", this._groundColor);
         }
 
-        public get grassColors(): BABYLON.Color3[] {
+        public get grassColors(): Color3[] {
             return this._grassColors;
         }
 
-        public set grassColors(value: BABYLON.Color3[]) {
+        public set grassColors(value: Color3[]) {
             this._grassColors = value;
             this.updateShaderUniforms();
         }
 
-        public get dirtColor(): BABYLON.Color3 {
-            return this._dirtColor;
-        }
-
-        public set dirtColor(value: BABYLON.Color3) {
-            this._dirtColor = value;
-            this.updateShaderUniforms();
-        }
-
-        public get groundColor(): BABYLON.Color3 {
+        public get groundColor(): Color3 {
             return this._groundColor;
         }
 
-        public set ground(value: BABYLON.Color3) {
+        public set groundColor(value: Color3) {
             this.groundColor = value;
             this.updateShaderUniforms();
         }
     }
 
     export class RoadProceduralTexture extends ProceduralTexture {
-        private _roadColor: BABYLON.Color3 = new BABYLON.Color3(0.53, 0.53, 0.53);
+        private _roadColor = new Color3(0.53, 0.53, 0.53);
 
         constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
             super(name, size, "road", scene, fallbackTexture, generateMipMaps);
@@ -265,11 +252,11 @@
             this.setColor3("roadColor", this._roadColor);
         }
 
-        public get roadColor(): BABYLON.Color3 {
+        public get roadColor(): Color3 {
             return this._roadColor;
         }
 
-        public set roadColor(value: BABYLON.Color3) {
+        public set roadColor(value: Color3) {
             this._roadColor = value;
             this.updateShaderUniforms();
         }
@@ -278,8 +265,8 @@
     export class BrickProceduralTexture extends ProceduralTexture {
         private _numberOfBricksHeight: number = 15;
         private _numberOfBricksWidth: number = 5;
-        private _jointColor: BABYLON.Color3 = new BABYLON.Color3(0.72, 0.72, 0.72);
-        private _brickColor: BABYLON.Color3 = new BABYLON.Color3(0.77, 0.47, 0.40);
+        private _jointColor = new Color3(0.72, 0.72, 0.72);
+        private _brickColor = new Color3(0.77, 0.47, 0.40);
 
         constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
             super(name, size, "brick", scene, fallbackTexture, generateMipMaps);
@@ -290,8 +277,8 @@
         public updateShaderUniforms() {
             this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
             this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
-            this.setColor3("brick", this._brickColor);
-            this.setColor3("joint", this._jointColor);
+            this.setColor3("brickColor", this._brickColor);
+            this.setColor3("jointColor", this._jointColor);
         }
 
         public get numberOfBricksHeight(): number {
@@ -312,20 +299,20 @@
             this.updateShaderUniforms();
         }
 
-        public get jointColor(): BABYLON.Color3 {
+        public get jointColor(): Color3 {
             return this._jointColor;
         }
 
-        public set jointColor(value: BABYLON.Color3) {
+        public set jointColor(value: Color3) {
             this._jointColor = value;
             this.updateShaderUniforms();
         }
 
-        public get brickColor(): BABYLON.Color3 {
+        public get brickColor(): Color3 {
             return this._brickColor;
         }
 
-        public set brickColor(value: BABYLON.Color3) {
+        public set brickColor(value: Color3) {
             this._brickColor = value;
             this.updateShaderUniforms();
         }
@@ -335,8 +322,8 @@
         private _numberOfTilesHeight: number = 3;
         private _numberOfTilesWidth: number = 3;
         private _amplitude: number = 9.0;
-        private _marbleColor: BABYLON.Color3 = new BABYLON.Color3(0.77, 0.47, 0.40);
-        private _jointColor: BABYLON.Color3 = new BABYLON.Color3(0.72, 0.72, 0.72);
+        private _marbleColor = new Color3(0.77, 0.47, 0.40);
+        private _jointColor = new Color3(0.72, 0.72, 0.72);
 
         constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
             super(name, size, "marble", scene, fallbackTexture, generateMipMaps);
@@ -345,11 +332,11 @@
         }
 
         public updateShaderUniforms() {
-            this.setFloat("numberOfBricksHeight", this._numberOfTilesHeight);
-            this.setFloat("numberOfBricksWidth", this._numberOfTilesWidth);
+            this.setFloat("numberOfTilesHeight", this._numberOfTilesHeight);
+            this.setFloat("numberOfTilesWidth", this._numberOfTilesWidth);
             this.setFloat("amplitude", this._amplitude);
-            this.setColor3("brick", this._marbleColor);
-            this.setColor3("joint", this._jointColor);
+            this.setColor3("marbleColor", this._marbleColor);
+            this.setColor3("jointColor", this._jointColor);
         }
 
         public get numberOfTilesHeight(): number {
@@ -370,20 +357,20 @@
             this.updateShaderUniforms();
         }
 
-        public get jointColor(): BABYLON.Color3 {
+        public get jointColor(): Color3 {
             return this._jointColor;
         }
 
-        public set jointColor(value: BABYLON.Color3) {
+        public set jointColor(value: Color3) {
             this._jointColor = value;
             this.updateShaderUniforms();
         }
 
-        public get marbleColor(): BABYLON.Color3 {
+        public get marbleColor(): Color3 {
             return this._marbleColor;
         }
 
-        public set marbleColor(value: BABYLON.Color3) {
+        public set marbleColor(value: Color3) {
             this._marbleColor = value;
             this.updateShaderUniforms();
         }

+ 1 - 1
Babylon/Materials/textures/babylon.baseTexture.js

@@ -116,7 +116,7 @@
             this._texture.references--;
 
             // Final reference ?
-            if (this._texture.references == 0) {
+            if (this._texture.references === 0) {
                 var index = texturesCache.indexOf(this._texture);
                 texturesCache.splice(index, 1);
 

+ 7 - 7
Babylon/Materials/textures/babylon.baseTexture.ts

@@ -1,18 +1,18 @@
 module BABYLON {
     export class BaseTexture {
         public name: string;
-        public delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
+        public delayLoadState = Engine.DELAYLOADSTATE_NONE;
         public hasAlpha = false;
         public getAlphaFromRGB = false;
         public level = 1;
-        public isCube = false
+        public isCube = false;
         public isRenderTarget = false;
         public animations = new Array<Animation>();
         public onDispose: () => void;
         public coordinatesIndex = 0;
-        public coordinatesMode = BABYLON.Texture.EXPLICIT_MODE;
-        public wrapU = BABYLON.Texture.WRAP_ADDRESSMODE;
-        public wrapV = BABYLON.Texture.WRAP_ADDRESSMODE;
+        public coordinatesMode = Texture.EXPLICIT_MODE;
+        public wrapU = Texture.WRAP_ADDRESSMODE;
+        public wrapV = Texture.WRAP_ADDRESSMODE;
         public anisotropicFilteringLevel = 4;
         public _cachedAnisotropicFilteringLevel: number;
 
@@ -41,7 +41,7 @@
         }
 
         public isReady(): boolean {
-            if (this.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {
+            if (this.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) {
                 return true;
             }
 
@@ -119,7 +119,7 @@
             this._texture.references--;
 
             // Final reference ?
-            if (this._texture.references == 0) {
+            if (this._texture.references === 0) {
                 var index = texturesCache.indexOf(this._texture);
                 texturesCache.splice(index, 1);
 

+ 1 - 1
Babylon/Mesh/babylon.abstractMesh.js

@@ -16,7 +16,7 @@ var BABYLON;
             this.scaling = new BABYLON.Vector3(1, 1, 1);
             this.billboardMode = BABYLON.AbstractMesh.BILLBOARDMODE_NONE;
             this.visibility = 1.0;
-            this.alphaLayer = Number.MAX_VALUE;
+            this.alphaIndex = Number.MAX_VALUE;
             this.infiniteDistance = false;
             this.isVisible = true;
             this.isPickable = true;

+ 1 - 1
Babylon/Mesh/babylon.abstractMesh.ts

@@ -34,7 +34,7 @@
         public scaling = new BABYLON.Vector3(1, 1, 1);
         public billboardMode = BABYLON.AbstractMesh.BILLBOARDMODE_NONE;
         public visibility = 1.0;
-        public alphaLayer = Number.MAX_VALUE;
+        public alphaIndex = Number.MAX_VALUE;
         public infiniteDistance = false;
         public isVisible = true;
         public isPickable = true;

+ 1 - 1
Babylon/Mesh/babylon.subMesh.ts

@@ -11,7 +11,7 @@
         public _lastColliderTransformMatrix: Matrix;
 
         public _renderId = 0;
-        public _alphaLayer: number;
+        public _alphaIndex: number;
         public _distanceToCamera: number;
         public _id: number;
 

+ 5 - 7
Babylon/Rendering/babylon.renderingGroup.js

@@ -48,18 +48,18 @@
             if (this._transparentSubMeshes.length) {
                 for (subIndex = 0; subIndex < this._transparentSubMeshes.length; subIndex++) {
                     submesh = this._transparentSubMeshes.data[subIndex];
-                    submesh._alphaLayer = submesh.getMesh().alphaLayer;
+                    submesh._alphaIndex = submesh.getMesh().alphaIndex;
                     submesh._distanceToCamera = submesh.getBoundingInfo().boundingSphere.centerWorld.subtract(this._scene.activeCamera.position).length();
                 }
 
                 var sortedArray = this._transparentSubMeshes.data.slice(0, this._transparentSubMeshes.length);
 
                 sortedArray.sort(function (a, b) {
-                    // Alpha layer first
-                    if (a._alphaLayer > b._alphaLayer) {
+                    // Alpha index first
+                    if (a._alphaIndex > b._alphaIndex) {
                         return 1;
                     }
-                    if (a._alphaLayer < b._alphaLayer) {
+                    if (a._alphaIndex < b._alphaIndex) {
                         return -1;
                     }
 
@@ -98,9 +98,7 @@
             var mesh = subMesh.getMesh();
 
             if (material.needAlphaBlending() || mesh.visibility < 1.0 || mesh.hasVertexAlpha) {
-                if (material.alpha > 0 || mesh.visibility < 1.0) {
-                    this._transparentSubMeshes.push(subMesh);
-                }
+                this._transparentSubMeshes.push(subMesh);
             } else if (material.needAlphaTesting()) {
                 this._alphaTestSubMeshes.push(subMesh);
             } else {

+ 6 - 8
Babylon/Rendering/babylon.renderingGroup.ts

@@ -11,7 +11,7 @@
         }
 
         public render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, beforeTransparents: () => void) => void,
-                      beforeTransparents): boolean {
+            beforeTransparents): boolean {
             if (customRenderFunction) {
                 customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, beforeTransparents);
                 return true;
@@ -51,18 +51,18 @@
                 // Sorting
                 for (subIndex = 0; subIndex < this._transparentSubMeshes.length; subIndex++) {
                     submesh = this._transparentSubMeshes.data[subIndex];
-                    submesh._alphaLayer = submesh.getMesh().alphaLayer;
+                    submesh._alphaIndex = submesh.getMesh().alphaIndex;
                     submesh._distanceToCamera = submesh.getBoundingInfo().boundingSphere.centerWorld.subtract(this._scene.activeCamera.position).length();
                 }
 
                 var sortedArray = this._transparentSubMeshes.data.slice(0, this._transparentSubMeshes.length);
 
                 sortedArray.sort((a, b) => {
-                    // Alpha layer first
-                    if (a._alphaLayer > b._alphaLayer) {
+                    // Alpha index first
+                    if (a._alphaIndex > b._alphaIndex) {
                         return 1;
                     }
-                    if (a._alphaLayer < b._alphaLayer) {
+                    if (a._alphaIndex < b._alphaIndex) {
                         return -1;
                     }
 
@@ -102,9 +102,7 @@
             var mesh = subMesh.getMesh();
 
             if (material.needAlphaBlending() || mesh.visibility < 1.0 || mesh.hasVertexAlpha) { // Transparent
-                if (material.alpha > 0 || mesh.visibility < 1.0) {
-                    this._transparentSubMeshes.push(subMesh);
-                }
+                this._transparentSubMeshes.push(subMesh);
             } else if (material.needAlphaTesting()) { // Alpha test
                 this._alphaTestSubMeshes.push(subMesh);
             } else {

+ 5 - 5
Babylon/Shaders/brick.fragment.fx

@@ -7,8 +7,8 @@ varying vec2 vUV;
 
 uniform float numberOfBricksHeight;
 uniform float numberOfBricksWidth;
-uniform vec3 brick;
-uniform vec3 joint;
+uniform vec3 brickColor;
+uniform vec3 jointColor;
 
 float rand(vec2 n) {
 	return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
@@ -40,7 +40,7 @@ void main(void)
 	float brickH = 1.0 / numberOfBricksHeight;
 	float jointWPercentage = 0.01;
 	float jointHPercentage = 0.05;
-	vec3 color = brick;
+	vec3 color = brickColor;
 	float yi = vUV.y / brickH;
 	float nyi = round(yi);
 	float xi = vUV.x / brickW;
@@ -53,10 +53,10 @@ void main(void)
 	vec2 brickvUV = vec2((xi - floor(xi)) / brickH, (yi - floor(yi)) /  brickW);
 
 	if (yi < nyi + jointHPercentage && yi > nyi - jointHPercentage){
-		color = mix(joint, vec3(0.37, 0.25, 0.25), (yi - nyi) / jointHPercentage + 0.2);
+		color = mix(jointColor, vec3(0.37, 0.25, 0.25), (yi - nyi) / jointHPercentage + 0.2);
 	}
 	else if (xi < nxi + jointWPercentage && xi > nxi - jointWPercentage){
-		color = mix(joint, vec3(0.44, 0.44, 0.44), (xi - nxi) / jointWPercentage + 0.2);
+		color = mix(jointColor, vec3(0.44, 0.44, 0.44), (xi - nxi) / jointWPercentage + 0.2);
 	}
 	else {
 		float brickColorSwitch = mod(floor(yi) + floor(xi), 3.0);

+ 3 - 3
Babylon/Shaders/fire.fragment.fx

@@ -2,7 +2,7 @@
 precision highp float;
 #endif
 
-uniform float iGlobalTime;
+uniform float time;
 uniform vec3 c1;
 uniform vec3 c2;
 uniform vec3 c3;
@@ -37,8 +37,8 @@ float fbm(vec2 n) {
 
 void main() {
 	vec2 p = vUV * 8.0;
-	float q = fbm(p - iGlobalTime * 0.1);
-	vec2 r = vec2(fbm(p + q + iGlobalTime * speed.x - p.x - p.y), fbm(p + q - iGlobalTime * speed.y));
+	float q = fbm(p - time * 0.1);
+	vec2 r = vec2(fbm(p + q + time * speed.x - p.x - p.y), fbm(p + q - time * speed.y));
 	vec3 c = mix(c1, c2, fbm(p + r)) + mix(c3, c4, r.x) - mix(c5, c6, r.y);
 	vec3 color = c * cos(shift * vUV.y);
 	float luminance = dot(color.rgb, vec3(0.3, 0.59, 0.11));

+ 8 - 9
Babylon/Shaders/grass.fragment.fx

@@ -5,11 +5,10 @@ precision highp float;
 varying vec2 vPosition;
 varying vec2 vUV;
 
-uniform vec3 herb1;
-uniform vec3 herb2;
-uniform vec3 herb3;
-uniform vec3 dirt;
-uniform vec3 ground;
+uniform vec3 herb1Color;
+uniform vec3 herb2Color;
+uniform vec3 herb3Color;
+uniform vec3 groundColor;
 
 float rand(vec2 n) {
 	return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
@@ -32,9 +31,9 @@ float fbm(vec2 n) {
 }
 
 void main(void) {
-	vec3 color = mix(ground, herb1, rand(gl_FragCoord.xy * 4.0));
-	color = mix(color, herb2, rand(gl_FragCoord.xy * 8.0));
-	color = mix(color, herb3, rand(gl_FragCoord.xy));
-	color = mix(color, herb1, fbm(gl_FragCoord.xy * 16.0));
+	vec3 color = mix(groundColor, herb1Color, rand(gl_FragCoord.xy * 4.0));
+	color = mix(color, herb2Color, rand(gl_FragCoord.xy * 8.0));
+	color = mix(color, herb3Color, rand(gl_FragCoord.xy));
+	color = mix(color, herb1Color, fbm(gl_FragCoord.xy * 16.0));
 	gl_FragColor = vec4(color, 1.0);
 }

+ 9 - 9
Babylon/Shaders/marble.fragment.fx

@@ -5,11 +5,11 @@ precision highp float;
 varying vec2 vPosition;
 varying vec2 vUV;
 
-uniform float numberOfBricksHeight;
-uniform float numberOfBricksWidth ;
+uniform float numberOfTilesHeight;
+uniform float numberOfTilesWidth;
 uniform float amplitude;
-uniform vec3 brick;
-uniform vec3 joint;
+uniform vec3 brickColor;
+uniform vec3 jointColor;
 
 const vec3 tileSize = vec3(1.1, 1.0, 1.1);
 const vec3 tilePct = vec3(0.98, 1.0, 0.98);
@@ -54,11 +54,11 @@ vec3 marble_color(float x)
 
 void main()
 {
-	float brickW = 1.0 / numberOfBricksWidth;
-	float brickH = 1.0 / numberOfBricksHeight;
+	float brickW = 1.0 / numberOfTilesWidth;
+	float brickH = 1.0 / numberOfTilesHeight;
 	float jointWPercentage = 0.01;
 	float jointHPercentage = 0.01;
-	vec3 color = brick;
+	vec3 color = brickColor;
 	float yi = vUV.y / brickH;
 	float nyi = round(yi);
 	float xi = vUV.x / brickW;
@@ -71,10 +71,10 @@ void main()
 	vec2 brickvUV = vec2((xi - floor(xi)) / brickH, (yi - floor(yi)) / brickW);
 
 	if (yi < nyi + jointHPercentage && yi > nyi - jointHPercentage){
-		color = mix(joint, vec3(0.37, 0.25, 0.25), (yi - nyi) / jointHPercentage + 0.2);
+		color = mix(jointColor, vec3(0.37, 0.25, 0.25), (yi - nyi) / jointHPercentage + 0.2);
 	}
 	else if (xi < nxi + jointWPercentage && xi > nxi - jointWPercentage){
-		color = mix(joint, vec3(0.44, 0.44, 0.44), (xi - nxi) / jointWPercentage + 0.2);
+		color = mix(jointColor, vec3(0.44, 0.44, 0.44), (xi - nxi) / jointWPercentage + 0.2);
 	}
 	else {
 		float t = 6.28 * brickvUV.x / (tileSize.x + noise(vec2(vUV)*6.0));

+ 6 - 0
Exporters/3ds Max/BabylonExport.Entities/BabylonMesh.cs

@@ -96,6 +96,12 @@ namespace BabylonExport.Entities
         [DataMember]
         public bool showSubMeshesBoundingBox { get; set; }
 
+        [DataMember]
+        public bool applyFog { get; set; }
+
+        [DataMember]
+        public int alphaIndex { get; set; }
+
         public BabylonMesh()
         {
             isEnabled = true;

BIN
Exporters/3ds Max/Max2Babylon-0.8.3.zip


BIN
Exporters/3ds Max/Max2Babylon-0.8.5.zip


+ 11 - 2
Exporters/3ds Max/Max2Babylon/Exporter/BabylonExporter.Camera.cs

@@ -25,8 +25,17 @@ namespace Max2Babylon
             }
 
             babylonCamera.fov = Tools.ConvertFov(maxCamera.GetFOV(0, Tools.Forever));
-            babylonCamera.minZ = maxCamera.GetEnvRange(0, 0, Tools.Forever);
-            babylonCamera.maxZ = maxCamera.GetEnvRange(0, 1, Tools.Forever);
+
+            if (maxCamera.ManualClip == 1)
+            {
+                babylonCamera.minZ = maxCamera.GetClipDist(0, 1, Tools.Forever);
+                babylonCamera.maxZ = maxCamera.GetClipDist(0, 2, Tools.Forever);
+            }
+            else
+            {
+                 babylonCamera.minZ = 0.1f;
+                 babylonCamera.maxZ = 10000.0f;
+            }
 
             if (babylonCamera.minZ == 0.0f)
             {

+ 2 - 0
Exporters/3ds Max/Max2Babylon/Exporter/BabylonExporter.Mesh.cs

@@ -43,6 +43,8 @@ namespace Max2Babylon
             babylonMesh.receiveShadows = meshNode.RcvShadows == 1;
             babylonMesh.showBoundingBox = meshNode.GetBoolProperty("babylonjs_showboundingbox");
             babylonMesh.showSubMeshesBoundingBox = meshNode.GetBoolProperty("babylonjs_showsubmeshesboundingbox");
+            babylonMesh.applyFog = meshNode.ApplyAtmospherics == 1;
+            babylonMesh.alphaIndex = (int)meshNode.GetFloatProperty("babylonjs_alphaindex", 1000);
 
             // Collisions
             babylonMesh.checkCollisions = meshNode.GetBoolProperty("babylonjs_checkcollisions");

+ 19 - 10
Exporters/3ds Max/Max2Babylon/Exporter/BabylonExporter.cs

@@ -119,6 +119,7 @@ namespace Max2Babylon
 
             // Cameras
             BabylonCamera mainCamera = null;
+            ICameraObject mainCameraNode = null;
 
             RaiseMessage("Exporting cameras");
             foreach (var cameraNode in maxScene.NodesListBySuperClass(SClass_ID.Camera))
@@ -131,6 +132,7 @@ namespace Max2Babylon
 
                 if (mainCamera == null && babylonScene.CamerasList.Count > 0)
                 {
+                    mainCameraNode = (cameraNode.ObjectRef as ICameraObject);
                     mainCamera = babylonScene.CamerasList[0];
                     babylonScene.activeCameraID = mainCamera.id;
                     RaiseMessage("Active camera set to " + mainCamera.name, Color.Green, 1, true);
@@ -155,19 +157,26 @@ namespace Max2Babylon
                 {
                     var fog = atmospheric as IStdFog;
 
+                    RaiseMessage("Exporting fog");
+
                     if (fog != null)
                     {
-                        RaiseMessage("Exporting fog");
-
                         babylonScene.fogColor = fog.GetColor(0).ToArray();
-                        babylonScene.fogDensity = fog.GetDensity(0);
-                        babylonScene.fogMode = fog.GetType_ == 0 ? 3 : 1;
-
-                        if (mainCamera != null)
-                        {
-                            babylonScene.fogStart = mainCamera.minZ*fog.GetNear(0);
-                            babylonScene.fogEnd = mainCamera.maxZ*fog.GetFar(0);
-                        }
+                        babylonScene.fogMode = 3;
+                    }
+#if !MAX2015
+                    else
+                    {
+                        var paramBlock = atmospheric.GetReference(0) as IIParamBlock;
+
+                        babylonScene.fogColor = Tools.GetParamBlockValueColor(paramBlock, "Fog Color");
+                        babylonScene.fogMode = 3;
+                    }
+#endif
+                    if (mainCamera != null)
+                    {
+                        babylonScene.fogStart = mainCameraNode.GetEnvRange(0, 0, Tools.Forever);
+                        babylonScene.fogEnd = mainCameraNode.GetEnvRange(0, 1, Tools.Forever);
                     }
                 }
             }

+ 34 - 5
Exporters/3ds Max/Max2Babylon/Forms/ObjectPropertiesForm.Designer.cs

@@ -46,12 +46,15 @@
             this.nupFrom = new System.Windows.Forms.NumericUpDown();
             this.label1 = new System.Windows.Forms.Label();
             this.chkAutoAnimate = new System.Windows.Forms.CheckBox();
+            this.nupAlphaIndex = new System.Windows.Forms.NumericUpDown();
+            this.label3 = new System.Windows.Forms.Label();
             this.groupBox1.SuspendLayout();
             this.groupBox2.SuspendLayout();
             this.groupBox3.SuspendLayout();
             this.grpAutoAnimate.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.nupTo)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.nupFrom)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.nupAlphaIndex)).BeginInit();
             this.SuspendLayout();
             // 
             // groupBox1
@@ -82,7 +85,7 @@
             this.butCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
             this.butCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
             this.butCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
-            this.butCancel.Location = new System.Drawing.Point(174, 419);
+            this.butCancel.Location = new System.Drawing.Point(174, 430);
             this.butCancel.Name = "butCancel";
             this.butCancel.Size = new System.Drawing.Size(75, 23);
             this.butCancel.TabIndex = 6;
@@ -94,7 +97,7 @@
             this.butOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
             this.butOK.DialogResult = System.Windows.Forms.DialogResult.OK;
             this.butOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
-            this.butOK.Location = new System.Drawing.Point(93, 419);
+            this.butOK.Location = new System.Drawing.Point(93, 430);
             this.butOK.Name = "butOK";
             this.butOK.Size = new System.Drawing.Size(75, 23);
             this.butOK.TabIndex = 5;
@@ -104,6 +107,8 @@
             // 
             // groupBox2
             // 
+            this.groupBox2.Controls.Add(this.nupAlphaIndex);
+            this.groupBox2.Controls.Add(this.label3);
             this.groupBox2.Controls.Add(this.chkNoExport);
             this.groupBox2.Controls.Add(this.chkShowSubMeshesBoundingBox);
             this.groupBox2.Controls.Add(this.chkShowBoundingBox);
@@ -112,7 +117,7 @@
             this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
             this.groupBox2.Location = new System.Drawing.Point(12, 77);
             this.groupBox2.Name = "groupBox2";
-            this.groupBox2.Size = new System.Drawing.Size(319, 154);
+            this.groupBox2.Size = new System.Drawing.Size(319, 179);
             this.groupBox2.TabIndex = 2;
             this.groupBox2.TabStop = false;
             this.groupBox2.Text = "Misc.";
@@ -182,7 +187,7 @@
             this.groupBox3.Controls.Add(this.grpAutoAnimate);
             this.groupBox3.Controls.Add(this.chkAutoAnimate);
             this.groupBox3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
-            this.groupBox3.Location = new System.Drawing.Point(12, 237);
+            this.groupBox3.Location = new System.Drawing.Point(12, 262);
             this.groupBox3.Name = "groupBox3";
             this.groupBox3.Size = new System.Drawing.Size(319, 156);
             this.groupBox3.TabIndex = 4;
@@ -270,13 +275,34 @@
             this.chkAutoAnimate.UseVisualStyleBackColor = true;
             this.chkAutoAnimate.CheckedChanged += new System.EventHandler(this.chkAutoAnimate_CheckedChanged);
             // 
+            // nupAlphaIndex
+            // 
+            this.nupAlphaIndex.Location = new System.Drawing.Point(89, 143);
+            this.nupAlphaIndex.Maximum = new decimal(new int[] {
+            1000,
+            0,
+            0,
+            0});
+            this.nupAlphaIndex.Name = "nupAlphaIndex";
+            this.nupAlphaIndex.Size = new System.Drawing.Size(120, 20);
+            this.nupAlphaIndex.TabIndex = 5;
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Location = new System.Drawing.Point(18, 145);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(65, 13);
+            this.label3.TabIndex = 6;
+            this.label3.Text = "Alpha index:";
+            // 
             // ObjectPropertiesForm
             // 
             this.AcceptButton = this.butOK;
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.CancelButton = this.butCancel;
-            this.ClientSize = new System.Drawing.Size(343, 454);
+            this.ClientSize = new System.Drawing.Size(343, 465);
             this.Controls.Add(this.groupBox3);
             this.Controls.Add(this.groupBox2);
             this.Controls.Add(this.butCancel);
@@ -297,6 +323,7 @@
             this.grpAutoAnimate.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.nupTo)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.nupFrom)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.nupAlphaIndex)).EndInit();
             this.ResumeLayout(false);
 
         }
@@ -321,5 +348,7 @@
         private System.Windows.Forms.Label label1;
         private System.Windows.Forms.CheckBox chkAutoAnimate;
         private System.Windows.Forms.CheckBox chkNoExport;
+        private System.Windows.Forms.NumericUpDown nupAlphaIndex;
+        private System.Windows.Forms.Label label3;
     }
 }

+ 3 - 0
Exporters/3ds Max/Max2Babylon/Forms/ObjectPropertiesForm.cs

@@ -27,6 +27,8 @@ namespace Max2Babylon
             Tools.UpdateCheckBox(chkLoop, objects, "babylonjs_autoanimateloop");
             Tools.UpdateNumericUpDown(nupFrom, objects, "babylonjs_autoanimate_from");
             Tools.UpdateNumericUpDown(nupTo, objects, "babylonjs_autoanimate_to");
+
+            Tools.UpdateNumericUpDown(nupAlphaIndex, objects, "babylonjs_alphaindex");
         }
 
         private void ObjectPropertiesForm_Load(object sender, EventArgs e)
@@ -52,6 +54,7 @@ namespace Max2Babylon
             Tools.PrepareCheckBox(chkLoop, objects, "babylonjs_autoanimateloop", 1);
             Tools.PrepareNumericUpDown(nupFrom, objects, "babylonjs_autoanimate_from");
             Tools.PrepareNumericUpDown(nupTo, objects, "babylonjs_autoanimate_to", 100.0f);
+            Tools.PrepareNumericUpDown(nupAlphaIndex, objects, "babylonjs_alphaindex", 1000);
         }
 
         private void chkAutoAnimate_CheckedChanged(object sender, EventArgs e)

+ 69 - 0
Exporters/3ds Max/Max2Babylon/Tools/Tools.cs

@@ -26,7 +26,58 @@ namespace Max2Babylon
 
         public static IMatrix3 Identity { get { return Loader.Global.Matrix3.Create(XAxis, YAxis, ZAxis, Origin); } }
 
+#if !MAX2015
+        unsafe public static int GetParamBlockIndex(IIParamBlock paramBlock, string name)
+        {
+            for (short index = 0; index < paramBlock.NumParams; index++)
+            {
+                IGetParamName gpn = Loader.Global.GetParamName.Create("", index);
+
+                paramBlock.NotifyDependents(Tools.Forever, (UIntPtr)gpn.Handle.ToPointer(), RefMessage.GetParamName, (SClass_ID)0xfffffff0, false, null);
+
+                if (gpn.Name == name)
+                {
+                    return index;
+                }
+            }
+
+            return -1;
+        }
+
+
+        public static int GetParamBlockValueInt(IIParamBlock paramBlock, string name)
+        {
+            var index = Tools.GetParamBlockIndex(paramBlock, name);
+
+            if (index == -1)
+            {
+                return 0;
+            }
+            return paramBlock.GetInt(index, 0);
+        }
+
+        public static float GetParamBlockValueFloat(IIParamBlock paramBlock, string name)
+        {
+            var index = Tools.GetParamBlockIndex(paramBlock, name);
+
+            if (index == -1)
+            {
+                return 0;
+            }
+            return paramBlock.GetFloat(index, 0);
+        }
+
+        public static float[] GetParamBlockValueColor(IIParamBlock paramBlock, string name)
+        {
+            var index = Tools.GetParamBlockIndex(paramBlock, name);
 
+            if (index == -1)
+            {
+                return null;
+            }
+            return paramBlock.GetColor(index, 0).ToArray();
+        }
+#endif
         public static Vector3 ToEulerAngles(this IQuat q)
         {
             // Store the Euler angles in radians
@@ -417,6 +468,24 @@ namespace Max2Babylon
             return true;
         }
 
+        public static bool IsAlmostEqualTo(this float[] current, float[] other, float epsilon)
+        {
+            if (current.Length != other.Length)
+            {
+                return false;
+            }
+
+            for (var index = 0; index < current.Length; index++)
+            {
+                if (Math.Abs(current[index] - other[index]) > epsilon)
+                {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
         public static bool GetBoolProperty(this IINode node, string propertyName, int defaultState = 0)
         {
             int state = defaultState;

+ 21 - 1
Exporters/3ds Max/Max2Babylon/Tools/WebServer.cs

@@ -28,15 +28,27 @@ namespace Max2Babylon
             margin: 0;
             overflow: hidden;
         }
+
+        #debugLayerButton {
+            position: absolute;
+            border: white solid 1px;
+            background: rgba(128, 128, 128, 0.3);
+            color: white;
+            left: 50%;
+            width: 100px;
+            margin-left:-50px;
+            bottom: 10px;
+        }
     </style>
 </head>
 
 <body>
     <canvas id='canvas'></canvas>
+    <button id='debugLayerButton'>Debug layer</button>
     <script type='text/javascript'>
         var canvas = document.getElementById('canvas');
         var engine = new BABYLON.Engine(canvas, true);
-
+       
         BABYLON.SceneLoader.Load('', '###SCENE###', engine, function (newScene) {
             newScene.activeCamera.attachControl(canvas);
 
@@ -47,6 +59,14 @@ namespace Max2Babylon
             window.addEventListener('resize', function () {
                 engine.resize();
             });
+
+            document.getElementById('debugLayerButton').addEventListener('click', function () {
+                if (newScene.debugLayer.isVisible()) {
+                    newScene.debugLayer.hide();
+                } else {
+                    newScene.debugLayer.show();
+                }
+            });
         });
     </script>
 </body>

ファイルの差分が大きいため隠しています
+ 195 - 110
babylon.2.0-alpha.debug.js


ファイルの差分が大きいため隠しています
+ 8 - 8
babylon.2.0-alpha.js