Bläddra i källkod

Improved alpha testing optimization

David Catuhe 7 år sedan
förälder
incheckning
f27e3618c0
66 ändrade filer med 21907 tillägg och 21609 borttagningar
  1. 5538 5517
      Playground/babylon.d.txt
  2. 5730 5709
      dist/preview release/babylon.d.ts
  3. 42 42
      dist/preview release/babylon.js
  4. 92 35
      dist/preview release/babylon.max.js
  5. 42 42
      dist/preview release/babylon.worker.js
  6. 9913 9892
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  7. 44 44
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  8. 93 36
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  9. 93 36
      dist/preview release/customConfigurations/minimalGLTFViewer/es6.js
  10. 92 35
      dist/preview release/es6.js
  11. 2 2
      dist/preview release/materialsLibrary/babylon.cellMaterial.js
  12. 1 1
      dist/preview release/materialsLibrary/babylon.cellMaterial.min.js
  13. 2 2
      dist/preview release/materialsLibrary/babylon.customMaterial.js
  14. 1 1
      dist/preview release/materialsLibrary/babylon.customMaterial.min.js
  15. 1 1
      dist/preview release/materialsLibrary/babylon.fireMaterial.js
  16. 1 1
      dist/preview release/materialsLibrary/babylon.fireMaterial.min.js
  17. 2 2
      dist/preview release/materialsLibrary/babylon.furMaterial.js
  18. 1 1
      dist/preview release/materialsLibrary/babylon.furMaterial.min.js
  19. 2 2
      dist/preview release/materialsLibrary/babylon.gradientMaterial.js
  20. 1 1
      dist/preview release/materialsLibrary/babylon.gradientMaterial.min.js
  21. 1 1
      dist/preview release/materialsLibrary/babylon.gridMaterial.js
  22. 1 1
      dist/preview release/materialsLibrary/babylon.gridMaterial.min.js
  23. 2 2
      dist/preview release/materialsLibrary/babylon.lavaMaterial.js
  24. 1 1
      dist/preview release/materialsLibrary/babylon.lavaMaterial.min.js
  25. 2 2
      dist/preview release/materialsLibrary/babylon.normalMaterial.js
  26. 1 1
      dist/preview release/materialsLibrary/babylon.normalMaterial.min.js
  27. 2 2
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.js
  28. 1 1
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js
  29. 2 2
      dist/preview release/materialsLibrary/babylon.simpleMaterial.js
  30. 1 1
      dist/preview release/materialsLibrary/babylon.simpleMaterial.min.js
  31. 1 1
      dist/preview release/materialsLibrary/babylon.skyMaterial.js
  32. 1 1
      dist/preview release/materialsLibrary/babylon.skyMaterial.min.js
  33. 2 2
      dist/preview release/materialsLibrary/babylon.terrainMaterial.js
  34. 1 1
      dist/preview release/materialsLibrary/babylon.terrainMaterial.min.js
  35. 2 2
      dist/preview release/materialsLibrary/babylon.triPlanarMaterial.js
  36. 1 1
      dist/preview release/materialsLibrary/babylon.triPlanarMaterial.min.js
  37. 2 2
      dist/preview release/materialsLibrary/babylon.waterMaterial.js
  38. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  39. 25 25
      dist/preview release/materialsLibrary/babylonjs.materials.js
  40. 6 6
      dist/preview release/materialsLibrary/babylonjs.materials.min.js
  41. 2 44
      dist/preview release/typedocValidationBaseline.json
  42. 55 55
      dist/preview release/viewer/babylon.viewer.js
  43. 1 0
      dist/preview release/what's new.md
  44. 2 2
      materialsLibrary/src/cell/babylon.cellMaterial.ts
  45. 2 2
      materialsLibrary/src/custom/babylon.customMaterial.ts
  46. 1 1
      materialsLibrary/src/fire/babylon.fireMaterial.ts
  47. 2 2
      materialsLibrary/src/fur/babylon.furMaterial.ts
  48. 2 2
      materialsLibrary/src/gradient/babylon.gradientMaterial.ts
  49. 1 1
      materialsLibrary/src/grid/babylon.gridmaterial.ts
  50. 2 2
      materialsLibrary/src/lava/babylon.lavaMaterial.ts
  51. 2 2
      materialsLibrary/src/normal/babylon.normalMaterial.ts
  52. 2 2
      materialsLibrary/src/shadowOnly/babylon.shadowOnlyMaterial.ts
  53. 2 2
      materialsLibrary/src/simple/babylon.simpleMaterial.ts
  54. 1 1
      materialsLibrary/src/sky/babylon.skyMaterial.ts
  55. 2 2
      materialsLibrary/src/terrain/babylon.terrainMaterial.ts
  56. 2 2
      materialsLibrary/src/triPlanar/babylon.triPlanarMaterial.ts
  57. 2 2
      materialsLibrary/src/water/babylon.waterMaterial.ts
  58. 2 2
      src/Materials/Background/babylon.backgroundMaterial.ts
  59. 3 3
      src/Materials/PBR/babylon.pbrBaseMaterial.ts
  60. 4 4
      src/Materials/PBR/babylon.pbrMaterial.ts
  61. 1 1
      src/Materials/Textures/babylon.baseTexture.ts
  62. 1 1
      src/Materials/babylon.fresnelParameters.ts
  63. 26 2
      src/Materials/babylon.material.ts
  64. 14 8
      src/Materials/babylon.materialHelper.ts
  65. 5 5
      src/Materials/babylon.standardMaterial.ts
  66. 19 1
      src/Mesh/babylon.abstractMesh.ts

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 5538 - 5517
Playground/babylon.d.txt


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 5730 - 5709
dist/preview release/babylon.d.ts


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 42 - 42
dist/preview release/babylon.js


+ 92 - 35
dist/preview release/babylon.max.js

@@ -11700,8 +11700,8 @@ var BABYLON;
             // establish the file extension, if possible
             var lastDot = url.lastIndexOf('.');
             var extension = (lastDot > 0) ? url.substring(lastDot).toLowerCase() : "";
-            var isDDS = this.getCaps().s3tc && (extension === ".dds");
-            var isTGA = (extension === ".tga");
+            var isDDS = this.getCaps().s3tc && (extension.indexOf(".dds") === 0);
+            var isTGA = (extension.indexOf(".tga") === 0);
             // determine if a ktx file should be substituted
             var isKTX = false;
             if (this._textureFormatInUse && !isBase64 && !fallBack) {
@@ -15688,7 +15688,7 @@ var BABYLON;
             _this._occlusionInternalRetryCounter = 0;
             _this._isOccluded = false;
             _this._isOcclusionQueryInProgress = false;
-            _this.visibility = 1.0;
+            _this._visibility = 1.0;
             _this.alphaIndex = Number.MAX_VALUE;
             _this.isVisible = true;
             _this.isPickable = true;
@@ -15923,6 +15923,26 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(AbstractMesh.prototype, "visibility", {
+            /**
+             * Gets or sets mesh visibility between 0 and 1 (defult is 1)
+             */
+            get: function () {
+                return this._visibility;
+            },
+            /**
+             * Gets or sets mesh visibility between 0 and 1 (defult is 1)
+             */
+            set: function (value) {
+                if (this._visibility === value) {
+                    return;
+                }
+                this._visibility = value;
+                this._markSubMeshesAsMiscDirty();
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(AbstractMesh.prototype, "material", {
             get: function () {
                 return this._material;
@@ -15970,6 +15990,7 @@ var BABYLON;
                 }
                 this._hasVertexAlpha = value;
                 this._markSubMeshesAsAttributesDirty();
+                this._markSubMeshesAsMiscDirty();
             },
             enumerable: true,
             configurable: true
@@ -24606,7 +24627,7 @@ var BABYLON;
                 }
                 this._hasAlpha = value;
                 if (this._scene) {
-                    this._scene.markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag);
+                    this._scene.markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag | BABYLON.Material.MiscDirtyFlag);
                 }
             },
             enumerable: true,
@@ -28933,7 +28954,7 @@ var BABYLON;
             this.checkReadyOnEveryCall = false;
             this.checkReadyOnlyOnce = false;
             this.state = "";
-            this.alpha = 1.0;
+            this._alpha = 1.0;
             this._backFaceCulling = true;
             this.doNotSerialize = false;
             this.storeEffectOnSubMeshes = false;
@@ -29089,6 +29110,20 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Material.prototype, "alpha", {
+            get: function () {
+                return this._alpha;
+            },
+            set: function (value) {
+                if (this._alpha === value) {
+                    return;
+                }
+                this._alpha = value;
+                this.markAsDirty(Material.MiscDirtyFlag);
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Material.prototype, "backFaceCulling", {
             get: function () {
                 return this._backFaceCulling;
@@ -29427,6 +29462,12 @@ var BABYLON;
         Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsFresnelDirty(); });
         };
+        Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
+            this._markAllSubMeshesAsDirty(function (defines) {
+                defines.markAsFresnelDirty();
+                defines.markAsMiscDirty();
+            });
+        };
         Material.prototype._markAllSubMeshesAsLightsDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
         };
@@ -29436,6 +29477,12 @@ var BABYLON;
         Material.prototype._markAllSubMeshesAsMiscDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsMiscDirty(); });
         };
+        Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
+            this._markAllSubMeshesAsDirty(function (defines) {
+                defines.markAsTexturesDirty();
+                defines.markAsMiscDirty();
+            });
+        };
         Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
             // Animations
             this.getScene().stopAnimation(this);
@@ -29549,8 +29596,8 @@ var BABYLON;
             BABYLON.serialize()
         ], Material.prototype, "state", void 0);
         __decorate([
-            BABYLON.serialize()
-        ], Material.prototype, "alpha", void 0);
+            BABYLON.serialize("alpha")
+        ], Material.prototype, "_alpha", void 0);
         __decorate([
             BABYLON.serialize("backFaceCulling")
         ], Material.prototype, "_backFaceCulling", void 0);
@@ -35886,32 +35933,39 @@ var BABYLON;
                 uniformBuffer.updateMatrix(key + "Matrix", matrix);
             }
         };
-        MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, defines) {
+        /**
+         * Helper used to prepare the list of defines associated with misc. values for shader compilation
+         * @param mesh defines the current mesh
+         * @param scene defines the current scene
+         * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
+         * @param pointsCloud defines if point cloud rendering has to be turned on
+         * @param fogEnabled defines if fog has to be turned on
+         * @param alphaTest defines if alpha testing has to be turned on
+         * @param defines defines the current list of defines
+         */
+        MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
             if (defines._areMiscDirty) {
                 defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
                 defines["POINTSIZE"] = (pointsCloud || scene.forcePointsCloud);
                 defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && fogEnabled);
                 defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
+                defines["ALPHATEST"] = alphaTest;
             }
         };
         /**
-         * Helper used to prepare the list of defines for shader compilation
+         * Helper used to prepare the list of defines associated with frame values for shader compilation
          * @param scene defines the current scene
          * @param engine defines the current engine
          * @param defines specifies the list of active defines
          * @param useInstances defines if instances have to be turned on
          * @param alphaTest defines if alpha testing has to be turned on
          */
-        MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, alphaTest) {
+        MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances) {
             var changed = false;
             if (defines["CLIPPLANE"] !== (scene.clipPlane !== undefined && scene.clipPlane !== null)) {
                 defines["CLIPPLANE"] = !defines["CLIPPLANE"];
                 changed = true;
             }
-            if (defines["ALPHATEST"] !== alphaTest) {
-                defines["ALPHATEST"] = !defines["ALPHATEST"];
-                changed = true;
-            }
             if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
                 defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
                 changed = true;
@@ -36887,11 +36941,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
             // Get correct effect      
             if (defines.isDirty) {
                 defines.markAsProcessed();
@@ -37543,7 +37597,7 @@ var BABYLON;
             BABYLON.serializeAsTexture("diffuseTexture")
         ], StandardMaterial.prototype, "_diffuseTexture", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], StandardMaterial.prototype, "diffuseTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture("ambientTexture")
@@ -37555,7 +37609,7 @@ var BABYLON;
             BABYLON.serializeAsTexture("opacityTexture")
         ], StandardMaterial.prototype, "_opacityTexture", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], StandardMaterial.prototype, "opacityTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture("reflectionTexture")
@@ -37687,7 +37741,7 @@ var BABYLON;
             BABYLON.serializeAsFresnelParameters("opacityFresnelParameters")
         ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsFresnelDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsFresnelAndMiscDirty")
         ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
         __decorate([
             BABYLON.serializeAsFresnelParameters("reflectionFresnelParameters")
@@ -38157,7 +38211,7 @@ var BABYLON;
                 }
                 this._transparencyMode = value;
                 this._forceAlphaTest = (value === BABYLON.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
-                this._markAllSubMeshesAsTexturesDirty();
+                this._markAllSubMeshesAsTexturesAndMiscDirty();
             },
             enumerable: true,
             configurable: true
@@ -38484,9 +38538,9 @@ var BABYLON;
             defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
             defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest);
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             if (BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== BABYLON.PBRMaterial.PBRMATERIAL_OPAQUE) && mesh) {
                 var bufferMesh = null;
@@ -39719,7 +39773,7 @@ var BABYLON;
         ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
         __decorate([
             BABYLON.serializeAsTexture(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "opacityTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture(),
@@ -39803,15 +39857,15 @@ var BABYLON;
         ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "forceAlphaTest", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "alphaCutOff", void 0);
         __decorate([
             BABYLON.serialize(),
@@ -59053,7 +59107,7 @@ var BABYLON;
                     return;
                 }
                 this._isEnabled = value;
-                BABYLON.Engine.MarkAllMaterialsAsDirty(BABYLON.Material.FresnelDirtyFlag);
+                BABYLON.Engine.MarkAllMaterialsAsDirty(BABYLON.Material.FresnelDirtyFlag | BABYLON.Material.MiscDirtyFlag);
             },
             enumerable: true,
             configurable: true
@@ -77271,9 +77325,8 @@ var BABYLON;
                 if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
                     // Moving the teleportation area to this targetted point
                     //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
-                    if (this._currentMeshSelected &&
-                        !this._isTeleportationFloor(this._currentMeshSelected)) {
-                        this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
+                    if (this._currentMeshSelected && !this._isTeleportationFloor(this._currentMeshSelected)) {
+                        this._notifySelectedMeshUnselected();
                     }
                     this._currentMeshSelected = null;
                     this._moveTeleportationSelectorTo(hit);
@@ -77304,9 +77357,7 @@ var BABYLON;
                         }
                     }
                     else {
-                        if (this._currentMeshSelected) {
-                            this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
-                        }
+                        this._notifySelectedMeshUnselected();
                         this._currentMeshSelected = null;
                         this.changeGazeColor(new BABYLON.Color3(0.7, 0.7, 0.7));
                         this.changeLaserColor(new BABYLON.Color3(0.7, 0.7, 0.7));
@@ -77315,6 +77366,7 @@ var BABYLON;
             }
             else {
                 this._currentHit = null;
+                this._notifySelectedMeshUnselected();
                 this._currentMeshSelected = null;
                 this._teleportationAllowed = false;
                 this._hideTeleportationTarget();
@@ -77322,6 +77374,11 @@ var BABYLON;
                 this.changeLaserColor(new BABYLON.Color3(0.7, 0.7, 0.7));
             }
         };
+        VRExperienceHelper.prototype._notifySelectedMeshUnselected = function () {
+            if (this._currentMeshSelected) {
+                this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
+            }
+        };
         /**
          * Sets the color of the laser ray from the vr controllers.
          * @param color new color for the ray.
@@ -84189,9 +84246,9 @@ var BABYLON;
                 this._imageProcessingConfiguration.prepareDefines(defines);
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
             // Attribs
             if (BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
                 if (mesh) {

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 42 - 42
dist/preview release/babylon.worker.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 9913 - 9892
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 44 - 44
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 93 - 36
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -11700,8 +11700,8 @@ var BABYLON;
             // establish the file extension, if possible
             var lastDot = url.lastIndexOf('.');
             var extension = (lastDot > 0) ? url.substring(lastDot).toLowerCase() : "";
-            var isDDS = this.getCaps().s3tc && (extension === ".dds");
-            var isTGA = (extension === ".tga");
+            var isDDS = this.getCaps().s3tc && (extension.indexOf(".dds") === 0);
+            var isTGA = (extension.indexOf(".tga") === 0);
             // determine if a ktx file should be substituted
             var isKTX = false;
             if (this._textureFormatInUse && !isBase64 && !fallBack) {
@@ -15688,7 +15688,7 @@ var BABYLON;
             _this._occlusionInternalRetryCounter = 0;
             _this._isOccluded = false;
             _this._isOcclusionQueryInProgress = false;
-            _this.visibility = 1.0;
+            _this._visibility = 1.0;
             _this.alphaIndex = Number.MAX_VALUE;
             _this.isVisible = true;
             _this.isPickable = true;
@@ -15923,6 +15923,26 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(AbstractMesh.prototype, "visibility", {
+            /**
+             * Gets or sets mesh visibility between 0 and 1 (defult is 1)
+             */
+            get: function () {
+                return this._visibility;
+            },
+            /**
+             * Gets or sets mesh visibility between 0 and 1 (defult is 1)
+             */
+            set: function (value) {
+                if (this._visibility === value) {
+                    return;
+                }
+                this._visibility = value;
+                this._markSubMeshesAsMiscDirty();
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(AbstractMesh.prototype, "material", {
             get: function () {
                 return this._material;
@@ -15970,6 +15990,7 @@ var BABYLON;
                 }
                 this._hasVertexAlpha = value;
                 this._markSubMeshesAsAttributesDirty();
+                this._markSubMeshesAsMiscDirty();
             },
             enumerable: true,
             configurable: true
@@ -24606,7 +24627,7 @@ var BABYLON;
                 }
                 this._hasAlpha = value;
                 if (this._scene) {
-                    this._scene.markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag);
+                    this._scene.markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag | BABYLON.Material.MiscDirtyFlag);
                 }
             },
             enumerable: true,
@@ -28933,7 +28954,7 @@ var BABYLON;
             this.checkReadyOnEveryCall = false;
             this.checkReadyOnlyOnce = false;
             this.state = "";
-            this.alpha = 1.0;
+            this._alpha = 1.0;
             this._backFaceCulling = true;
             this.doNotSerialize = false;
             this.storeEffectOnSubMeshes = false;
@@ -29089,6 +29110,20 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Material.prototype, "alpha", {
+            get: function () {
+                return this._alpha;
+            },
+            set: function (value) {
+                if (this._alpha === value) {
+                    return;
+                }
+                this._alpha = value;
+                this.markAsDirty(Material.MiscDirtyFlag);
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Material.prototype, "backFaceCulling", {
             get: function () {
                 return this._backFaceCulling;
@@ -29427,6 +29462,12 @@ var BABYLON;
         Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsFresnelDirty(); });
         };
+        Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
+            this._markAllSubMeshesAsDirty(function (defines) {
+                defines.markAsFresnelDirty();
+                defines.markAsMiscDirty();
+            });
+        };
         Material.prototype._markAllSubMeshesAsLightsDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
         };
@@ -29436,6 +29477,12 @@ var BABYLON;
         Material.prototype._markAllSubMeshesAsMiscDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsMiscDirty(); });
         };
+        Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
+            this._markAllSubMeshesAsDirty(function (defines) {
+                defines.markAsTexturesDirty();
+                defines.markAsMiscDirty();
+            });
+        };
         Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
             // Animations
             this.getScene().stopAnimation(this);
@@ -29549,8 +29596,8 @@ var BABYLON;
             BABYLON.serialize()
         ], Material.prototype, "state", void 0);
         __decorate([
-            BABYLON.serialize()
-        ], Material.prototype, "alpha", void 0);
+            BABYLON.serialize("alpha")
+        ], Material.prototype, "_alpha", void 0);
         __decorate([
             BABYLON.serialize("backFaceCulling")
         ], Material.prototype, "_backFaceCulling", void 0);
@@ -35886,32 +35933,39 @@ var BABYLON;
                 uniformBuffer.updateMatrix(key + "Matrix", matrix);
             }
         };
-        MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, defines) {
+        /**
+         * Helper used to prepare the list of defines associated with misc. values for shader compilation
+         * @param mesh defines the current mesh
+         * @param scene defines the current scene
+         * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
+         * @param pointsCloud defines if point cloud rendering has to be turned on
+         * @param fogEnabled defines if fog has to be turned on
+         * @param alphaTest defines if alpha testing has to be turned on
+         * @param defines defines the current list of defines
+         */
+        MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
             if (defines._areMiscDirty) {
                 defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
                 defines["POINTSIZE"] = (pointsCloud || scene.forcePointsCloud);
                 defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && fogEnabled);
                 defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
+                defines["ALPHATEST"] = alphaTest;
             }
         };
         /**
-         * Helper used to prepare the list of defines for shader compilation
+         * Helper used to prepare the list of defines associated with frame values for shader compilation
          * @param scene defines the current scene
          * @param engine defines the current engine
          * @param defines specifies the list of active defines
          * @param useInstances defines if instances have to be turned on
          * @param alphaTest defines if alpha testing has to be turned on
          */
-        MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, alphaTest) {
+        MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances) {
             var changed = false;
             if (defines["CLIPPLANE"] !== (scene.clipPlane !== undefined && scene.clipPlane !== null)) {
                 defines["CLIPPLANE"] = !defines["CLIPPLANE"];
                 changed = true;
             }
-            if (defines["ALPHATEST"] !== alphaTest) {
-                defines["ALPHATEST"] = !defines["ALPHATEST"];
-                changed = true;
-            }
             if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
                 defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
                 changed = true;
@@ -36887,11 +36941,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
             // Get correct effect      
             if (defines.isDirty) {
                 defines.markAsProcessed();
@@ -37543,7 +37597,7 @@ var BABYLON;
             BABYLON.serializeAsTexture("diffuseTexture")
         ], StandardMaterial.prototype, "_diffuseTexture", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], StandardMaterial.prototype, "diffuseTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture("ambientTexture")
@@ -37555,7 +37609,7 @@ var BABYLON;
             BABYLON.serializeAsTexture("opacityTexture")
         ], StandardMaterial.prototype, "_opacityTexture", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], StandardMaterial.prototype, "opacityTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture("reflectionTexture")
@@ -37687,7 +37741,7 @@ var BABYLON;
             BABYLON.serializeAsFresnelParameters("opacityFresnelParameters")
         ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsFresnelDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsFresnelAndMiscDirty")
         ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
         __decorate([
             BABYLON.serializeAsFresnelParameters("reflectionFresnelParameters")
@@ -38157,7 +38211,7 @@ var BABYLON;
                 }
                 this._transparencyMode = value;
                 this._forceAlphaTest = (value === BABYLON.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
-                this._markAllSubMeshesAsTexturesDirty();
+                this._markAllSubMeshesAsTexturesAndMiscDirty();
             },
             enumerable: true,
             configurable: true
@@ -38484,9 +38538,9 @@ var BABYLON;
             defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
             defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest);
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             if (BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== BABYLON.PBRMaterial.PBRMATERIAL_OPAQUE) && mesh) {
                 var bufferMesh = null;
@@ -39719,7 +39773,7 @@ var BABYLON;
         ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
         __decorate([
             BABYLON.serializeAsTexture(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "opacityTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture(),
@@ -39803,15 +39857,15 @@ var BABYLON;
         ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "forceAlphaTest", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "alphaCutOff", void 0);
         __decorate([
             BABYLON.serialize(),
@@ -58847,7 +58901,7 @@ var BABYLON;
                     return;
                 }
                 this._isEnabled = value;
-                BABYLON.Engine.MarkAllMaterialsAsDirty(BABYLON.Material.FresnelDirtyFlag);
+                BABYLON.Engine.MarkAllMaterialsAsDirty(BABYLON.Material.FresnelDirtyFlag | BABYLON.Material.MiscDirtyFlag);
             },
             enumerable: true,
             configurable: true
@@ -77065,9 +77119,8 @@ var BABYLON;
                 if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
                     // Moving the teleportation area to this targetted point
                     //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
-                    if (this._currentMeshSelected &&
-                        !this._isTeleportationFloor(this._currentMeshSelected)) {
-                        this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
+                    if (this._currentMeshSelected && !this._isTeleportationFloor(this._currentMeshSelected)) {
+                        this._notifySelectedMeshUnselected();
                     }
                     this._currentMeshSelected = null;
                     this._moveTeleportationSelectorTo(hit);
@@ -77098,9 +77151,7 @@ var BABYLON;
                         }
                     }
                     else {
-                        if (this._currentMeshSelected) {
-                            this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
-                        }
+                        this._notifySelectedMeshUnselected();
                         this._currentMeshSelected = null;
                         this.changeGazeColor(new BABYLON.Color3(0.7, 0.7, 0.7));
                         this.changeLaserColor(new BABYLON.Color3(0.7, 0.7, 0.7));
@@ -77109,6 +77160,7 @@ var BABYLON;
             }
             else {
                 this._currentHit = null;
+                this._notifySelectedMeshUnselected();
                 this._currentMeshSelected = null;
                 this._teleportationAllowed = false;
                 this._hideTeleportationTarget();
@@ -77116,6 +77168,11 @@ var BABYLON;
                 this.changeLaserColor(new BABYLON.Color3(0.7, 0.7, 0.7));
             }
         };
+        VRExperienceHelper.prototype._notifySelectedMeshUnselected = function () {
+            if (this._currentMeshSelected) {
+                this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
+            }
+        };
         /**
          * Sets the color of the laser ray from the vr controllers.
          * @param color new color for the ray.
@@ -83633,9 +83690,9 @@ var BABYLON;
                 this._imageProcessingConfiguration.prepareDefines(defines);
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
             // Attribs
             if (BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
                 if (mesh) {
@@ -84628,7 +84685,7 @@ var BABYLON;
                 defines.PREMULTIPLYALPHA = !defines.PREMULTIPLYALPHA;
                 defines.markAsUnprocessed();
             }
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, false, defines);
             // Get correct effect      
             if (defines.isDirty) {
                 defines.markAsProcessed();

+ 93 - 36
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js

@@ -11686,8 +11686,8 @@ var BABYLON;
             // establish the file extension, if possible
             var lastDot = url.lastIndexOf('.');
             var extension = (lastDot > 0) ? url.substring(lastDot).toLowerCase() : "";
-            var isDDS = this.getCaps().s3tc && (extension === ".dds");
-            var isTGA = (extension === ".tga");
+            var isDDS = this.getCaps().s3tc && (extension.indexOf(".dds") === 0);
+            var isTGA = (extension.indexOf(".tga") === 0);
             // determine if a ktx file should be substituted
             var isKTX = false;
             if (this._textureFormatInUse && !isBase64 && !fallBack) {
@@ -15674,7 +15674,7 @@ var BABYLON;
             _this._occlusionInternalRetryCounter = 0;
             _this._isOccluded = false;
             _this._isOcclusionQueryInProgress = false;
-            _this.visibility = 1.0;
+            _this._visibility = 1.0;
             _this.alphaIndex = Number.MAX_VALUE;
             _this.isVisible = true;
             _this.isPickable = true;
@@ -15909,6 +15909,26 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(AbstractMesh.prototype, "visibility", {
+            /**
+             * Gets or sets mesh visibility between 0 and 1 (defult is 1)
+             */
+            get: function () {
+                return this._visibility;
+            },
+            /**
+             * Gets or sets mesh visibility between 0 and 1 (defult is 1)
+             */
+            set: function (value) {
+                if (this._visibility === value) {
+                    return;
+                }
+                this._visibility = value;
+                this._markSubMeshesAsMiscDirty();
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(AbstractMesh.prototype, "material", {
             get: function () {
                 return this._material;
@@ -15956,6 +15976,7 @@ var BABYLON;
                 }
                 this._hasVertexAlpha = value;
                 this._markSubMeshesAsAttributesDirty();
+                this._markSubMeshesAsMiscDirty();
             },
             enumerable: true,
             configurable: true
@@ -24592,7 +24613,7 @@ var BABYLON;
                 }
                 this._hasAlpha = value;
                 if (this._scene) {
-                    this._scene.markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag);
+                    this._scene.markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag | BABYLON.Material.MiscDirtyFlag);
                 }
             },
             enumerable: true,
@@ -28919,7 +28940,7 @@ var BABYLON;
             this.checkReadyOnEveryCall = false;
             this.checkReadyOnlyOnce = false;
             this.state = "";
-            this.alpha = 1.0;
+            this._alpha = 1.0;
             this._backFaceCulling = true;
             this.doNotSerialize = false;
             this.storeEffectOnSubMeshes = false;
@@ -29075,6 +29096,20 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Material.prototype, "alpha", {
+            get: function () {
+                return this._alpha;
+            },
+            set: function (value) {
+                if (this._alpha === value) {
+                    return;
+                }
+                this._alpha = value;
+                this.markAsDirty(Material.MiscDirtyFlag);
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Material.prototype, "backFaceCulling", {
             get: function () {
                 return this._backFaceCulling;
@@ -29413,6 +29448,12 @@ var BABYLON;
         Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsFresnelDirty(); });
         };
+        Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
+            this._markAllSubMeshesAsDirty(function (defines) {
+                defines.markAsFresnelDirty();
+                defines.markAsMiscDirty();
+            });
+        };
         Material.prototype._markAllSubMeshesAsLightsDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
         };
@@ -29422,6 +29463,12 @@ var BABYLON;
         Material.prototype._markAllSubMeshesAsMiscDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsMiscDirty(); });
         };
+        Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
+            this._markAllSubMeshesAsDirty(function (defines) {
+                defines.markAsTexturesDirty();
+                defines.markAsMiscDirty();
+            });
+        };
         Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
             // Animations
             this.getScene().stopAnimation(this);
@@ -29535,8 +29582,8 @@ var BABYLON;
             BABYLON.serialize()
         ], Material.prototype, "state", void 0);
         __decorate([
-            BABYLON.serialize()
-        ], Material.prototype, "alpha", void 0);
+            BABYLON.serialize("alpha")
+        ], Material.prototype, "_alpha", void 0);
         __decorate([
             BABYLON.serialize("backFaceCulling")
         ], Material.prototype, "_backFaceCulling", void 0);
@@ -35872,32 +35919,39 @@ var BABYLON;
                 uniformBuffer.updateMatrix(key + "Matrix", matrix);
             }
         };
-        MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, defines) {
+        /**
+         * Helper used to prepare the list of defines associated with misc. values for shader compilation
+         * @param mesh defines the current mesh
+         * @param scene defines the current scene
+         * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
+         * @param pointsCloud defines if point cloud rendering has to be turned on
+         * @param fogEnabled defines if fog has to be turned on
+         * @param alphaTest defines if alpha testing has to be turned on
+         * @param defines defines the current list of defines
+         */
+        MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
             if (defines._areMiscDirty) {
                 defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
                 defines["POINTSIZE"] = (pointsCloud || scene.forcePointsCloud);
                 defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && fogEnabled);
                 defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
+                defines["ALPHATEST"] = alphaTest;
             }
         };
         /**
-         * Helper used to prepare the list of defines for shader compilation
+         * Helper used to prepare the list of defines associated with frame values for shader compilation
          * @param scene defines the current scene
          * @param engine defines the current engine
          * @param defines specifies the list of active defines
          * @param useInstances defines if instances have to be turned on
          * @param alphaTest defines if alpha testing has to be turned on
          */
-        MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, alphaTest) {
+        MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances) {
             var changed = false;
             if (defines["CLIPPLANE"] !== (scene.clipPlane !== undefined && scene.clipPlane !== null)) {
                 defines["CLIPPLANE"] = !defines["CLIPPLANE"];
                 changed = true;
             }
-            if (defines["ALPHATEST"] !== alphaTest) {
-                defines["ALPHATEST"] = !defines["ALPHATEST"];
-                changed = true;
-            }
             if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
                 defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
                 changed = true;
@@ -36873,11 +36927,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
             // Get correct effect      
             if (defines.isDirty) {
                 defines.markAsProcessed();
@@ -37529,7 +37583,7 @@ var BABYLON;
             BABYLON.serializeAsTexture("diffuseTexture")
         ], StandardMaterial.prototype, "_diffuseTexture", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], StandardMaterial.prototype, "diffuseTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture("ambientTexture")
@@ -37541,7 +37595,7 @@ var BABYLON;
             BABYLON.serializeAsTexture("opacityTexture")
         ], StandardMaterial.prototype, "_opacityTexture", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], StandardMaterial.prototype, "opacityTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture("reflectionTexture")
@@ -37673,7 +37727,7 @@ var BABYLON;
             BABYLON.serializeAsFresnelParameters("opacityFresnelParameters")
         ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsFresnelDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsFresnelAndMiscDirty")
         ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
         __decorate([
             BABYLON.serializeAsFresnelParameters("reflectionFresnelParameters")
@@ -38143,7 +38197,7 @@ var BABYLON;
                 }
                 this._transparencyMode = value;
                 this._forceAlphaTest = (value === BABYLON.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
-                this._markAllSubMeshesAsTexturesDirty();
+                this._markAllSubMeshesAsTexturesAndMiscDirty();
             },
             enumerable: true,
             configurable: true
@@ -38470,9 +38524,9 @@ var BABYLON;
             defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
             defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest);
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             if (BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== BABYLON.PBRMaterial.PBRMATERIAL_OPAQUE) && mesh) {
                 var bufferMesh = null;
@@ -39705,7 +39759,7 @@ var BABYLON;
         ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
         __decorate([
             BABYLON.serializeAsTexture(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "opacityTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture(),
@@ -39789,15 +39843,15 @@ var BABYLON;
         ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "forceAlphaTest", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "alphaCutOff", void 0);
         __decorate([
             BABYLON.serialize(),
@@ -58833,7 +58887,7 @@ var BABYLON;
                     return;
                 }
                 this._isEnabled = value;
-                BABYLON.Engine.MarkAllMaterialsAsDirty(BABYLON.Material.FresnelDirtyFlag);
+                BABYLON.Engine.MarkAllMaterialsAsDirty(BABYLON.Material.FresnelDirtyFlag | BABYLON.Material.MiscDirtyFlag);
             },
             enumerable: true,
             configurable: true
@@ -77051,9 +77105,8 @@ var BABYLON;
                 if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
                     // Moving the teleportation area to this targetted point
                     //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
-                    if (this._currentMeshSelected &&
-                        !this._isTeleportationFloor(this._currentMeshSelected)) {
-                        this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
+                    if (this._currentMeshSelected && !this._isTeleportationFloor(this._currentMeshSelected)) {
+                        this._notifySelectedMeshUnselected();
                     }
                     this._currentMeshSelected = null;
                     this._moveTeleportationSelectorTo(hit);
@@ -77084,9 +77137,7 @@ var BABYLON;
                         }
                     }
                     else {
-                        if (this._currentMeshSelected) {
-                            this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
-                        }
+                        this._notifySelectedMeshUnselected();
                         this._currentMeshSelected = null;
                         this.changeGazeColor(new BABYLON.Color3(0.7, 0.7, 0.7));
                         this.changeLaserColor(new BABYLON.Color3(0.7, 0.7, 0.7));
@@ -77095,6 +77146,7 @@ var BABYLON;
             }
             else {
                 this._currentHit = null;
+                this._notifySelectedMeshUnselected();
                 this._currentMeshSelected = null;
                 this._teleportationAllowed = false;
                 this._hideTeleportationTarget();
@@ -77102,6 +77154,11 @@ var BABYLON;
                 this.changeLaserColor(new BABYLON.Color3(0.7, 0.7, 0.7));
             }
         };
+        VRExperienceHelper.prototype._notifySelectedMeshUnselected = function () {
+            if (this._currentMeshSelected) {
+                this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
+            }
+        };
         /**
          * Sets the color of the laser ray from the vr controllers.
          * @param color new color for the ray.
@@ -83619,9 +83676,9 @@ var BABYLON;
                 this._imageProcessingConfiguration.prepareDefines(defines);
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
             // Attribs
             if (BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
                 if (mesh) {
@@ -84614,7 +84671,7 @@ var BABYLON;
                 defines.PREMULTIPLYALPHA = !defines.PREMULTIPLYALPHA;
                 defines.markAsUnprocessed();
             }
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, false, defines);
             // Get correct effect      
             if (defines.isDirty) {
                 defines.markAsProcessed();

+ 92 - 35
dist/preview release/es6.js

@@ -11686,8 +11686,8 @@ var BABYLON;
             // establish the file extension, if possible
             var lastDot = url.lastIndexOf('.');
             var extension = (lastDot > 0) ? url.substring(lastDot).toLowerCase() : "";
-            var isDDS = this.getCaps().s3tc && (extension === ".dds");
-            var isTGA = (extension === ".tga");
+            var isDDS = this.getCaps().s3tc && (extension.indexOf(".dds") === 0);
+            var isTGA = (extension.indexOf(".tga") === 0);
             // determine if a ktx file should be substituted
             var isKTX = false;
             if (this._textureFormatInUse && !isBase64 && !fallBack) {
@@ -15674,7 +15674,7 @@ var BABYLON;
             _this._occlusionInternalRetryCounter = 0;
             _this._isOccluded = false;
             _this._isOcclusionQueryInProgress = false;
-            _this.visibility = 1.0;
+            _this._visibility = 1.0;
             _this.alphaIndex = Number.MAX_VALUE;
             _this.isVisible = true;
             _this.isPickable = true;
@@ -15909,6 +15909,26 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(AbstractMesh.prototype, "visibility", {
+            /**
+             * Gets or sets mesh visibility between 0 and 1 (defult is 1)
+             */
+            get: function () {
+                return this._visibility;
+            },
+            /**
+             * Gets or sets mesh visibility between 0 and 1 (defult is 1)
+             */
+            set: function (value) {
+                if (this._visibility === value) {
+                    return;
+                }
+                this._visibility = value;
+                this._markSubMeshesAsMiscDirty();
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(AbstractMesh.prototype, "material", {
             get: function () {
                 return this._material;
@@ -15956,6 +15976,7 @@ var BABYLON;
                 }
                 this._hasVertexAlpha = value;
                 this._markSubMeshesAsAttributesDirty();
+                this._markSubMeshesAsMiscDirty();
             },
             enumerable: true,
             configurable: true
@@ -24592,7 +24613,7 @@ var BABYLON;
                 }
                 this._hasAlpha = value;
                 if (this._scene) {
-                    this._scene.markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag);
+                    this._scene.markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag | BABYLON.Material.MiscDirtyFlag);
                 }
             },
             enumerable: true,
@@ -28919,7 +28940,7 @@ var BABYLON;
             this.checkReadyOnEveryCall = false;
             this.checkReadyOnlyOnce = false;
             this.state = "";
-            this.alpha = 1.0;
+            this._alpha = 1.0;
             this._backFaceCulling = true;
             this.doNotSerialize = false;
             this.storeEffectOnSubMeshes = false;
@@ -29075,6 +29096,20 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Material.prototype, "alpha", {
+            get: function () {
+                return this._alpha;
+            },
+            set: function (value) {
+                if (this._alpha === value) {
+                    return;
+                }
+                this._alpha = value;
+                this.markAsDirty(Material.MiscDirtyFlag);
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Material.prototype, "backFaceCulling", {
             get: function () {
                 return this._backFaceCulling;
@@ -29413,6 +29448,12 @@ var BABYLON;
         Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsFresnelDirty(); });
         };
+        Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
+            this._markAllSubMeshesAsDirty(function (defines) {
+                defines.markAsFresnelDirty();
+                defines.markAsMiscDirty();
+            });
+        };
         Material.prototype._markAllSubMeshesAsLightsDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
         };
@@ -29422,6 +29463,12 @@ var BABYLON;
         Material.prototype._markAllSubMeshesAsMiscDirty = function () {
             this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsMiscDirty(); });
         };
+        Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
+            this._markAllSubMeshesAsDirty(function (defines) {
+                defines.markAsTexturesDirty();
+                defines.markAsMiscDirty();
+            });
+        };
         Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
             // Animations
             this.getScene().stopAnimation(this);
@@ -29535,8 +29582,8 @@ var BABYLON;
             BABYLON.serialize()
         ], Material.prototype, "state", void 0);
         __decorate([
-            BABYLON.serialize()
-        ], Material.prototype, "alpha", void 0);
+            BABYLON.serialize("alpha")
+        ], Material.prototype, "_alpha", void 0);
         __decorate([
             BABYLON.serialize("backFaceCulling")
         ], Material.prototype, "_backFaceCulling", void 0);
@@ -35872,32 +35919,39 @@ var BABYLON;
                 uniformBuffer.updateMatrix(key + "Matrix", matrix);
             }
         };
-        MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, defines) {
+        /**
+         * Helper used to prepare the list of defines associated with misc. values for shader compilation
+         * @param mesh defines the current mesh
+         * @param scene defines the current scene
+         * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
+         * @param pointsCloud defines if point cloud rendering has to be turned on
+         * @param fogEnabled defines if fog has to be turned on
+         * @param alphaTest defines if alpha testing has to be turned on
+         * @param defines defines the current list of defines
+         */
+        MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
             if (defines._areMiscDirty) {
                 defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
                 defines["POINTSIZE"] = (pointsCloud || scene.forcePointsCloud);
                 defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && fogEnabled);
                 defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
+                defines["ALPHATEST"] = alphaTest;
             }
         };
         /**
-         * Helper used to prepare the list of defines for shader compilation
+         * Helper used to prepare the list of defines associated with frame values for shader compilation
          * @param scene defines the current scene
          * @param engine defines the current engine
          * @param defines specifies the list of active defines
          * @param useInstances defines if instances have to be turned on
          * @param alphaTest defines if alpha testing has to be turned on
          */
-        MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, alphaTest) {
+        MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances) {
             var changed = false;
             if (defines["CLIPPLANE"] !== (scene.clipPlane !== undefined && scene.clipPlane !== null)) {
                 defines["CLIPPLANE"] = !defines["CLIPPLANE"];
                 changed = true;
             }
-            if (defines["ALPHATEST"] !== alphaTest) {
-                defines["ALPHATEST"] = !defines["ALPHATEST"];
-                changed = true;
-            }
             if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
                 defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
                 changed = true;
@@ -36873,11 +36927,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
             // Get correct effect      
             if (defines.isDirty) {
                 defines.markAsProcessed();
@@ -37529,7 +37583,7 @@ var BABYLON;
             BABYLON.serializeAsTexture("diffuseTexture")
         ], StandardMaterial.prototype, "_diffuseTexture", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], StandardMaterial.prototype, "diffuseTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture("ambientTexture")
@@ -37541,7 +37595,7 @@ var BABYLON;
             BABYLON.serializeAsTexture("opacityTexture")
         ], StandardMaterial.prototype, "_opacityTexture", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], StandardMaterial.prototype, "opacityTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture("reflectionTexture")
@@ -37673,7 +37727,7 @@ var BABYLON;
             BABYLON.serializeAsFresnelParameters("opacityFresnelParameters")
         ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
         __decorate([
-            BABYLON.expandToProperty("_markAllSubMeshesAsFresnelDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsFresnelAndMiscDirty")
         ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
         __decorate([
             BABYLON.serializeAsFresnelParameters("reflectionFresnelParameters")
@@ -38143,7 +38197,7 @@ var BABYLON;
                 }
                 this._transparencyMode = value;
                 this._forceAlphaTest = (value === BABYLON.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
-                this._markAllSubMeshesAsTexturesDirty();
+                this._markAllSubMeshesAsTexturesAndMiscDirty();
             },
             enumerable: true,
             configurable: true
@@ -38470,9 +38524,9 @@ var BABYLON;
             defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
             defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest);
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             if (BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== BABYLON.PBRMaterial.PBRMATERIAL_OPAQUE) && mesh) {
                 var bufferMesh = null;
@@ -39705,7 +39759,7 @@ var BABYLON;
         ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
         __decorate([
             BABYLON.serializeAsTexture(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "opacityTexture", void 0);
         __decorate([
             BABYLON.serializeAsTexture(),
@@ -39789,15 +39843,15 @@ var BABYLON;
         ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "forceAlphaTest", void 0);
         __decorate([
             BABYLON.serialize(),
-            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
+            BABYLON.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         ], PBRMaterial.prototype, "alphaCutOff", void 0);
         __decorate([
             BABYLON.serialize(),
@@ -59039,7 +59093,7 @@ var BABYLON;
                     return;
                 }
                 this._isEnabled = value;
-                BABYLON.Engine.MarkAllMaterialsAsDirty(BABYLON.Material.FresnelDirtyFlag);
+                BABYLON.Engine.MarkAllMaterialsAsDirty(BABYLON.Material.FresnelDirtyFlag | BABYLON.Material.MiscDirtyFlag);
             },
             enumerable: true,
             configurable: true
@@ -77257,9 +77311,8 @@ var BABYLON;
                 if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
                     // Moving the teleportation area to this targetted point
                     //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
-                    if (this._currentMeshSelected &&
-                        !this._isTeleportationFloor(this._currentMeshSelected)) {
-                        this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
+                    if (this._currentMeshSelected && !this._isTeleportationFloor(this._currentMeshSelected)) {
+                        this._notifySelectedMeshUnselected();
                     }
                     this._currentMeshSelected = null;
                     this._moveTeleportationSelectorTo(hit);
@@ -77290,9 +77343,7 @@ var BABYLON;
                         }
                     }
                     else {
-                        if (this._currentMeshSelected) {
-                            this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
-                        }
+                        this._notifySelectedMeshUnselected();
                         this._currentMeshSelected = null;
                         this.changeGazeColor(new BABYLON.Color3(0.7, 0.7, 0.7));
                         this.changeLaserColor(new BABYLON.Color3(0.7, 0.7, 0.7));
@@ -77301,6 +77352,7 @@ var BABYLON;
             }
             else {
                 this._currentHit = null;
+                this._notifySelectedMeshUnselected();
                 this._currentMeshSelected = null;
                 this._teleportationAllowed = false;
                 this._hideTeleportationTarget();
@@ -77308,6 +77360,11 @@ var BABYLON;
                 this.changeLaserColor(new BABYLON.Color3(0.7, 0.7, 0.7));
             }
         };
+        VRExperienceHelper.prototype._notifySelectedMeshUnselected = function () {
+            if (this._currentMeshSelected) {
+                this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
+            }
+        };
         /**
          * Sets the color of the laser ray from the vr controllers.
          * @param color new color for the ray.
@@ -84175,9 +84232,9 @@ var BABYLON;
                 this._imageProcessingConfiguration.prepareDefines(defines);
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
             // Attribs
             if (BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
                 if (mesh) {

+ 2 - 2
dist/preview release/materialsLibrary/babylon.cellMaterial.js

@@ -98,11 +98,11 @@ var BABYLON;
             // High level
             defines.CELLBASIC = !this.computeHighLevel;
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.cellMaterial.min.js


+ 2 - 2
dist/preview release/materialsLibrary/babylon.customMaterial.js

@@ -563,11 +563,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Get correct effect      
             if (defines.isDirty) {
                 defines.markAsProcessed();

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.customMaterial.min.js


+ 1 - 1
dist/preview release/materialsLibrary/babylon.fireMaterial.js

@@ -94,7 +94,7 @@ var BABYLON;
                 defines.FOG = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled);
             }
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
             // Get correct effect      

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.fireMaterial.min.js


+ 2 - 2
dist/preview release/materialsLibrary/babylon.furMaterial.js

@@ -143,11 +143,11 @@ var BABYLON;
                 defines.markAsUnprocessed();
             }
             // Misc.   
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.furMaterial.min.js


+ 2 - 2
dist/preview release/materialsLibrary/babylon.gradientMaterial.js

@@ -118,8 +118,8 @@ var BABYLON;
                 }
             }
             var engine = scene.getEngine();
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.gradientMaterial.min.js


+ 1 - 1
dist/preview release/materialsLibrary/babylon.gridMaterial.js

@@ -110,7 +110,7 @@ var BABYLON;
                 defines.PREMULTIPLYALPHA = !defines.PREMULTIPLYALPHA;
                 defines.markAsUnprocessed();
             }
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, false, defines);
             // Get correct effect      
             if (defines.isDirty) {
                 defines.markAsProcessed();

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.gridMaterial.min.js


+ 2 - 2
dist/preview release/materialsLibrary/babylon.lavaMaterial.js

@@ -131,11 +131,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.lavaMaterial.min.js


+ 2 - 2
dist/preview release/materialsLibrary/babylon.normalMaterial.js

@@ -125,11 +125,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.normalMaterial.min.js


+ 2 - 2
dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.js

@@ -86,8 +86,8 @@ var BABYLON;
                     }
                 }
             }
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, 1);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js


+ 2 - 2
dist/preview release/materialsLibrary/babylon.simpleMaterial.js

@@ -92,11 +92,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.simpleMaterial.min.js


+ 1 - 1
dist/preview release/materialsLibrary/babylon.skyMaterial.js

@@ -76,7 +76,7 @@ var BABYLON;
                     return true;
                 }
             }
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, false, defines);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, false);
             // Get correct effect      

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.skyMaterial.min.js


+ 2 - 2
dist/preview release/materialsLibrary/babylon.terrainMaterial.js

@@ -98,11 +98,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.terrainMaterial.min.js


+ 2 - 2
dist/preview release/materialsLibrary/babylon.triPlanarMaterial.js

@@ -117,11 +117,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.triPlanarMaterial.min.js


+ 2 - 2
dist/preview release/materialsLibrary/babylon.waterMaterial.js

@@ -228,8 +228,8 @@ var BABYLON;
                     }
                 }
             }
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             if (defines._areMiscDirty) {
                 if (this._fresnelSeparate) {
                     defines.FRESNELSEPARATE = true;

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
dist/preview release/materialsLibrary/babylon.waterMaterial.min.js


+ 25 - 25
dist/preview release/materialsLibrary/babylonjs.materials.js

@@ -96,8 +96,8 @@ var BABYLON;
                     }
                 }
             }
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, 1);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
@@ -326,8 +326,8 @@ var BABYLON;
                 }
             }
             var engine = scene.getEngine();
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
@@ -611,11 +611,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      
@@ -922,11 +922,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      
@@ -1234,11 +1234,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      
@@ -1642,8 +1642,8 @@ var BABYLON;
                     }
                 }
             }
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             if (defines._areMiscDirty) {
                 if (this._fresnelSeparate) {
                     defines.FRESNELSEPARATE = true;
@@ -2124,7 +2124,7 @@ var BABYLON;
                 defines.FOG = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled);
             }
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
             // Get correct effect      
@@ -2494,11 +2494,11 @@ var BABYLON;
                 defines.markAsUnprocessed();
             }
             // Misc.   
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      
@@ -2911,11 +2911,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      
@@ -3317,11 +3317,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      
@@ -3658,7 +3658,7 @@ var BABYLON;
                     return true;
                 }
             }
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, false, defines);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, false);
             // Get correct effect      
@@ -3907,7 +3907,7 @@ var BABYLON;
                 defines.PREMULTIPLYALPHA = !defines.PREMULTIPLYALPHA;
                 defines.markAsUnprocessed();
             }
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, false, defines);
             // Get correct effect      
             if (defines.isDirty) {
                 defines.markAsProcessed();
@@ -4559,11 +4559,11 @@ var BABYLON;
                 }
             }
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Get correct effect      
             if (defines.isDirty) {
                 defines.markAsProcessed();
@@ -6149,11 +6149,11 @@ var BABYLON;
             // High level
             defines.CELLBASIC = !this.computeHighLevel;
             // Misc.
-            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
             // Lights
             defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
             // Get correct effect      

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 6 - 6
dist/preview release/materialsLibrary/babylonjs.materials.min.js


+ 2 - 44
dist/preview release/typedocValidationBaseline.json

@@ -1,7 +1,7 @@
 {
-  "errors": 8788,
+  "errors": 8780,
   "babylon.typedoc.json": {
-    "errors": 8788,
+    "errors": 8780,
     "AnimationKeyInterpolation": {
       "Enumeration": {
         "Comments": {
@@ -569,11 +569,6 @@
             "MissingText": true
           }
         },
-        "visibility": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
         "OCCLUSION_ALGORITHM_TYPE_ACCURATE": {
           "Comments": {
             "MissingText": true
@@ -19504,43 +19499,6 @@
             }
           }
         },
-        "PrepareDefinesForMisc": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "mesh": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "scene": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "useLogarithmicDepth": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "pointsCloud": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "fogEnabled": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "defines": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
         "PrepareUniformsAndSamplersList": {
           "Comments": {
             "MissingText": true

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 55 - 55
dist/preview release/viewer/babylon.viewer.js


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

@@ -6,6 +6,7 @@
 - New [AnimationGroup class](http://doc.babylonjs.com/how_to/group) to control simultaneously multiple animations with different targets ([deltakosh](https://github.com/deltakosh))
 - `WebVRCamera` now supports GearVR ([brianzinn](https://github.com/brianzinn))
 - New glTF [serializer](https://github.com/BabylonJS/Babylon.js/tree/master/serializers/src/glTF/2.0). You can now export glTF or glb files directly from a Babylon scene ([kcoley](https://github.com/kcoley))
+- Babylon.js now uses Promises in addition to callbacks. We created several `xxxAsync` functions all over the framework (`SceneLoader.AppendAsync` for instance, which returns a Promise). A polyfill is also integrated to support older browsers ([deltakosh](https://github.com/deltakosh))
 
 ## Updates
 - Tons of functions and classes received the code comments they deserved (All the community)

+ 2 - 2
materialsLibrary/src/cell/babylon.cellMaterial.ts

@@ -110,13 +110,13 @@ module BABYLON {
             defines.CELLBASIC = !this.computeHighLevel;
 
             // Misc.
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             // Lights
             defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
             // Attribs
             MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);

+ 2 - 2
materialsLibrary/src/custom/babylon.customMaterial.ts

@@ -719,13 +719,13 @@ module BABYLON {
             }
 
             // Misc.
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             // Attribs
             MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
             // Get correct effect      
             if (defines.isDirty) {

+ 1 - 1
materialsLibrary/src/fire/babylon.fireMaterial.ts

@@ -107,7 +107,7 @@ module BABYLON {
             }
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
             // Attribs
             MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);

+ 2 - 2
materialsLibrary/src/fur/babylon.furMaterial.ts

@@ -181,13 +181,13 @@ module BABYLON {
             }
 
             // Misc.   
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             // Lights
             defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
             // Attribs
             MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);

+ 2 - 2
materialsLibrary/src/gradient/babylon.gradientMaterial.ts

@@ -128,9 +128,9 @@ module BABYLON {
 
             var engine = scene.getEngine();
 
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
 

+ 1 - 1
materialsLibrary/src/grid/babylon.gridmaterial.ts

@@ -120,7 +120,7 @@ module BABYLON {
                 defines.markAsUnprocessed();
             }
 
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, false, defines);
 
             // Get correct effect      
             if (defines.isDirty) {

+ 2 - 2
materialsLibrary/src/lava/babylon.lavaMaterial.ts

@@ -153,13 +153,13 @@ module BABYLON {
             }
 
             // Misc.
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             // Lights
             defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
             // Attribs
             MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);

+ 2 - 2
materialsLibrary/src/normal/babylon.normalMaterial.ts

@@ -132,13 +132,13 @@ module BABYLON {
             }
 
             // Misc.
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             // Lights
             defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
             // Attribs
             MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);

+ 2 - 2
materialsLibrary/src/shadowOnly/babylon.shadowOnlyMaterial.ts

@@ -86,9 +86,9 @@ module BABYLON {
                 }
             }
 
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, 1);
 

+ 2 - 2
materialsLibrary/src/simple/babylon.simpleMaterial.ts

@@ -99,13 +99,13 @@ module BABYLON {
             }
 
             // Misc.
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             // Lights
             defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
             // Attribs
             MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);

+ 1 - 1
materialsLibrary/src/sky/babylon.skyMaterial.ts

@@ -88,7 +88,7 @@ module BABYLON {
                 }
             }
 
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, false, defines);
             
             // Attribs
             MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, false);

+ 2 - 2
materialsLibrary/src/terrain/babylon.terrainMaterial.ts

@@ -140,13 +140,13 @@ module BABYLON {
             }
 
             // Misc.
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             // Lights
             defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
             // Attribs
             MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);

+ 2 - 2
materialsLibrary/src/triPlanar/babylon.triPlanarMaterial.ts

@@ -161,13 +161,13 @@ module BABYLON {
             }
 
             // Misc.
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             // Lights
             defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
             // Attribs
             MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);

+ 2 - 2
materialsLibrary/src/water/babylon.waterMaterial.ts

@@ -275,9 +275,9 @@ module BABYLON {
                 }
             }
 
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             if (defines._areMiscDirty) {
                 if (this._fresnelSeparate) {

+ 2 - 2
src/Materials/Background/babylon.backgroundMaterial.ts

@@ -696,10 +696,10 @@
             }
 
             // Misc.
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
 
             // Attribs
             if (MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true, false)) {

+ 3 - 3
src/Materials/PBR/babylon.pbrBaseMaterial.ts

@@ -537,7 +537,7 @@
 
             this._forceAlphaTest = (value === PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
 
-            this._markAllSubMeshesAsTexturesDirty();
+            this._markAllSubMeshesAsTexturesAndMiscDirty();
         }
 
         /**
@@ -901,10 +901,10 @@
             defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
 
             // Misc.
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest);
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
 
             // Attribs
             if (MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRMaterial.PBRMATERIAL_OPAQUE) && mesh) {

+ 4 - 4
src/Materials/PBR/babylon.pbrMaterial.ts

@@ -101,7 +101,7 @@
         public ambientTextureStrength: number = 1.0;
 
         @serializeAsTexture()
-        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        @expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         public opacityTexture: BaseTexture;
 
         @serializeAsTexture()
@@ -225,21 +225,21 @@
          * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
          */
         @serialize()
-        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        @expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         public useAlphaFromAlbedoTexture = false;
 
         /**
          * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
          */
         @serialize()
-        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        @expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         public forceAlphaTest = false;
 
         /**
          * Defines the alpha limits in alpha test mode.
          */
         @serialize()
-        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        @expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         public alphaCutOff = 0.4;
 
         /**

+ 1 - 1
src/Materials/Textures/babylon.baseTexture.ts

@@ -13,7 +13,7 @@
             }
             this._hasAlpha = value;
             if (this._scene) {
-                this._scene.markAllMaterialsAsDirty(Material.TextureDirtyFlag);
+                this._scene.markAllMaterialsAsDirty(Material.TextureDirtyFlag | Material.MiscDirtyFlag);
             }
         }
         public get hasAlpha(): boolean {

+ 1 - 1
src/Materials/babylon.fresnelParameters.ts

@@ -10,7 +10,7 @@
             }
 
             this._isEnabled = value;
-            Engine.MarkAllMaterialsAsDirty(Material.FresnelDirtyFlag);
+            Engine.MarkAllMaterialsAsDirty(Material.FresnelDirtyFlag | Material.MiscDirtyFlag);
         }   
 
         public leftColor = Color3.White();

+ 26 - 2
src/Materials/babylon.material.ts

@@ -251,8 +251,18 @@
         @serialize()
         public state = "";
 
-        @serialize()
-        public alpha = 1.0;
+        @serialize("alpha")
+        protected _alpha = 1.0;
+        public set alpha(value: number) {
+            if (this._alpha === value) {
+                return;
+            }
+            this._alpha = value;
+            this.markAsDirty(Material.MiscDirtyFlag);
+        }
+        public get alpha(): number {
+            return this._alpha;
+        }        
 
         @serialize("backFaceCulling")
         protected _backFaceCulling = true;
@@ -708,6 +718,13 @@
             this._markAllSubMeshesAsDirty(defines => defines.markAsFresnelDirty());
         }
 
+        protected _markAllSubMeshesAsFresnelAndMiscDirty() {
+            this._markAllSubMeshesAsDirty(defines => {
+                defines.markAsFresnelDirty();
+                defines.markAsMiscDirty();
+            });
+        }        
+
         protected _markAllSubMeshesAsLightsDirty() {
             this._markAllSubMeshesAsDirty(defines => defines.markAsLightDirty());
         }
@@ -720,6 +737,13 @@
             this._markAllSubMeshesAsDirty(defines => defines.markAsMiscDirty());
         }
 
+        protected _markAllSubMeshesAsTexturesAndMiscDirty() {
+            this._markAllSubMeshesAsDirty(defines => {
+                defines.markAsTexturesDirty();
+                defines.markAsMiscDirty();
+            });
+        }        
+
         public dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void {
             // Animations
             this.getScene().stopAnimation(this);

+ 14 - 8
src/Materials/babylon.materialHelper.ts

@@ -32,24 +32,35 @@
             }
         }
 
-        public static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, defines: any): void {
+        /**
+         * Helper used to prepare the list of defines associated with misc. values for shader compilation
+         * @param mesh defines the current mesh
+         * @param scene defines the current scene
+         * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
+         * @param pointsCloud defines if point cloud rendering has to be turned on
+         * @param fogEnabled defines if fog has to be turned on
+         * @param alphaTest defines if alpha testing has to be turned on
+         * @param defines defines the current list of defines
+         */
+        public static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void {
             if (defines._areMiscDirty) {
                 defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
                 defines["POINTSIZE"] = (pointsCloud || scene.forcePointsCloud);
                 defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && fogEnabled);
                 defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
+                defines["ALPHATEST"] = alphaTest;
             }
         }
 
         /**
-         * Helper used to prepare the list of defines for shader compilation
+         * Helper used to prepare the list of defines associated with frame values for shader compilation
          * @param scene defines the current scene
          * @param engine defines the current engine
          * @param defines specifies the list of active defines
          * @param useInstances defines if instances have to be turned on
          * @param alphaTest defines if alpha testing has to be turned on
          */
-        public static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, alphaTest: boolean): void {
+        public static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean): void {
             var changed = false;
 
             if (defines["CLIPPLANE"] !== (scene.clipPlane !== undefined && scene.clipPlane !== null)) {
@@ -57,11 +68,6 @@
                 changed = true;
             }
 
-            if (defines["ALPHATEST"] !== alphaTest) {
-                defines["ALPHATEST"] = !defines["ALPHATEST"];
-                changed = true;
-            }
-
             if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
                 defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
                 changed = true;

+ 5 - 5
src/Materials/babylon.standardMaterial.ts

@@ -108,7 +108,7 @@ module BABYLON {
     export class StandardMaterial extends PushMaterial {
         @serializeAsTexture("diffuseTexture")
         private _diffuseTexture: Nullable<BaseTexture>;;
-        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        @expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         public diffuseTexture: Nullable<BaseTexture>;;
 
         @serializeAsTexture("ambientTexture")
@@ -118,7 +118,7 @@ module BABYLON {
 
         @serializeAsTexture("opacityTexture")
         private _opacityTexture: Nullable<BaseTexture>;;
-        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        @expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         public opacityTexture: Nullable<BaseTexture>;;
 
         @serializeAsTexture("reflectionTexture")
@@ -233,7 +233,7 @@ module BABYLON {
 
         @serializeAsFresnelParameters("opacityFresnelParameters")
         private _opacityFresnelParameters: FresnelParameters;
-        @expandToProperty("_markAllSubMeshesAsFresnelDirty")
+        @expandToProperty("_markAllSubMeshesAsFresnelAndMiscDirty")
         public opacityFresnelParameters: FresnelParameters;
 
 
@@ -739,13 +739,13 @@ module BABYLON {
             }
 
             // Misc.
-            MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, defines);
+            MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
 
             // Attribs
             MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
 
             // Values that need to be evaluated on every frame
-            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances, this._shouldTurnAlphaTestOn(mesh));
+            MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
 
             // Get correct effect      
             if (defines.isDirty) {

+ 19 - 1
src/Mesh/babylon.abstractMesh.ts

@@ -205,7 +205,24 @@
 
         private _occlusionQuery: Nullable<WebGLQuery>;
 
-        public visibility = 1.0;
+        private _visibility = 1.0;
+        /**
+         * Gets or sets mesh visibility between 0 and 1 (defult is 1)
+         */
+        public get visibility(): number {
+            return this._visibility;
+        }
+        /**
+         * Gets or sets mesh visibility between 0 and 1 (defult is 1)
+         */        
+        public set visibility(value: number) {
+            if (this._visibility === value) {
+                return;
+            }
+
+            this._visibility = value;
+            this._markSubMeshesAsMiscDirty();
+        }        
         public alphaIndex = Number.MAX_VALUE;
         public isVisible = true;
         public isPickable = true;
@@ -269,6 +286,7 @@
 
             this._hasVertexAlpha = value;
             this._markSubMeshesAsAttributesDirty();
+            this._markSubMeshesAsMiscDirty();
         }
 
         private _useVertexColors = true;