Browse Source

Fix tiny stuff

David Catuhe 7 years ago
parent
commit
bf62734ae9

File diff suppressed because it is too large
+ 776 - 776
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 776 - 776
dist/preview release/babylon.module.d.ts


File diff suppressed because it is too large
+ 1630 - 1630
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


File diff suppressed because it is too large
+ 1630 - 1630
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 6 - 0
dist/preview release/gui/babylon.gui.js

@@ -156,9 +156,15 @@ var BABYLON;
             });
             });
             Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
             Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
                 get: function () {
                 get: function () {
+                    if (!this.layer) {
+                        return true;
+                    }
                     return (!this.layer.isBackground);
                     return (!this.layer.isBackground);
                 },
                 },
                 set: function (value) {
                 set: function (value) {
+                    if (!this.layer) {
+                        return;
+                    }
                     if (this.layer.isBackground === !value) {
                     if (this.layer.isBackground === !value) {
                         return;
                         return;
                     }
                     }

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


+ 4 - 6
dist/preview release/materialsLibrary/babylon.customMaterial.d.ts

@@ -54,15 +54,12 @@ declare module BABYLON {
         REFRACTION: boolean;
         REFRACTION: boolean;
         REFRACTIONMAP_3D: boolean;
         REFRACTIONMAP_3D: boolean;
         REFLECTIONOVERALPHA: boolean;
         REFLECTIONOVERALPHA: boolean;
-        INVERTNORMALMAPX: boolean;
-        INVERTNORMALMAPY: boolean;
         TWOSIDEDLIGHTING: boolean;
         TWOSIDEDLIGHTING: boolean;
         SHADOWFLOAT: boolean;
         SHADOWFLOAT: boolean;
         MORPHTARGETS: boolean;
         MORPHTARGETS: boolean;
         MORPHTARGETS_NORMAL: boolean;
         MORPHTARGETS_NORMAL: boolean;
         MORPHTARGETS_TANGENT: boolean;
         MORPHTARGETS_TANGENT: boolean;
         NUM_MORPH_INFLUENCERS: number;
         NUM_MORPH_INFLUENCERS: number;
-        USERIGHTHANDEDSYSTEM: boolean;
         IMAGEPROCESSING: boolean;
         IMAGEPROCESSING: boolean;
         VIGNETTE: boolean;
         VIGNETTE: boolean;
         VIGNETTEBLENDMODEMULTIPLY: boolean;
         VIGNETTEBLENDMODEMULTIPLY: boolean;
@@ -71,6 +68,7 @@ declare module BABYLON {
         CONTRAST: boolean;
         CONTRAST: boolean;
         COLORCURVES: boolean;
         COLORCURVES: boolean;
         COLORGRADING: boolean;
         COLORGRADING: boolean;
+        COLORGRADING3D: boolean;
         SAMPLER3DGREENDEPTH: boolean;
         SAMPLER3DGREENDEPTH: boolean;
         SAMPLER3DBGRMAP: boolean;
         SAMPLER3DBGRMAP: boolean;
         IMAGEPROCESSINGPOSTPROCESS: boolean;
         IMAGEPROCESSINGPOSTPROCESS: boolean;
@@ -177,7 +175,7 @@ declare module BABYLON {
          * Attaches a new image processing configuration to the Standard Material.
          * Attaches a new image processing configuration to the Standard Material.
          * @param configuration
          * @param configuration
          */
          */
-        protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration): void;
+        protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
         /**
         /**
          * Gets wether the color curves effect is enabled.
          * Gets wether the color curves effect is enabled.
          */
          */
@@ -223,7 +221,7 @@ declare module BABYLON {
         /**
         /**
          * Sets the Color Grading 2D Lookup Texture.
          * Sets the Color Grading 2D Lookup Texture.
          */
          */
-        cameraColorGradingTexture: BaseTexture;
+        cameraColorGradingTexture: Nullable<BaseTexture>;
         customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines_OldVer) => string;
         customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines_OldVer) => string;
         protected _renderTargets: SmartArray<RenderTargetTexture>;
         protected _renderTargets: SmartArray<RenderTargetTexture>;
         protected _worldViewProjectionMatrix: Matrix;
         protected _worldViewProjectionMatrix: Matrix;
@@ -295,7 +293,7 @@ declare module BABYLON {
         constructor();
         constructor();
     }
     }
     class StandardShaderVersions {
     class StandardShaderVersions {
-        static Ver3_0: any;
+        static Ver3_0: string;
     }
     }
     class CustomMaterial extends StandardMaterial_OldVer {
     class CustomMaterial extends StandardMaterial_OldVer {
         static ShaderIndexer: number;
         static ShaderIndexer: number;

+ 23 - 17
dist/preview release/materialsLibrary/babylon.customMaterial.js

@@ -75,15 +75,12 @@ var BABYLON;
             _this.REFRACTION = false;
             _this.REFRACTION = false;
             _this.REFRACTIONMAP_3D = false;
             _this.REFRACTIONMAP_3D = false;
             _this.REFLECTIONOVERALPHA = false;
             _this.REFLECTIONOVERALPHA = false;
-            _this.INVERTNORMALMAPX = false;
-            _this.INVERTNORMALMAPY = false;
             _this.TWOSIDEDLIGHTING = false;
             _this.TWOSIDEDLIGHTING = false;
             _this.SHADOWFLOAT = false;
             _this.SHADOWFLOAT = false;
             _this.MORPHTARGETS = false;
             _this.MORPHTARGETS = false;
             _this.MORPHTARGETS_NORMAL = false;
             _this.MORPHTARGETS_NORMAL = false;
             _this.MORPHTARGETS_TANGENT = false;
             _this.MORPHTARGETS_TANGENT = false;
             _this.NUM_MORPH_INFLUENCERS = 0;
             _this.NUM_MORPH_INFLUENCERS = 0;
-            _this.USERIGHTHANDEDSYSTEM = false;
             _this.IMAGEPROCESSING = false;
             _this.IMAGEPROCESSING = false;
             _this.VIGNETTE = false;
             _this.VIGNETTE = false;
             _this.VIGNETTEBLENDMODEMULTIPLY = false;
             _this.VIGNETTEBLENDMODEMULTIPLY = false;
@@ -92,6 +89,7 @@ var BABYLON;
             _this.CONTRAST = false;
             _this.CONTRAST = false;
             _this.COLORCURVES = false;
             _this.COLORCURVES = false;
             _this.COLORGRADING = false;
             _this.COLORGRADING = false;
+            _this.COLORGRADING3D = false;
             _this.SAMPLER3DGREENDEPTH = false;
             _this.SAMPLER3DGREENDEPTH = false;
             _this.SAMPLER3DBGRMAP = false;
             _this.SAMPLER3DBGRMAP = false;
             _this.IMAGEPROCESSINGPOSTPROCESS = false;
             _this.IMAGEPROCESSINGPOSTPROCESS = false;
@@ -498,8 +496,6 @@ var BABYLON;
                         else {
                         else {
                             defines._needUVs = true;
                             defines._needUVs = true;
                             defines.BUMP = true;
                             defines.BUMP = true;
-                            defines.INVERTNORMALMAPX = this.invertNormalMapX;
-                            defines.INVERTNORMALMAPY = this.invertNormalMapY;
                             defines.PARALLAX = this._useParallax;
                             defines.PARALLAX = this._useParallax;
                             defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
                             defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
                         }
                         }
@@ -568,12 +564,7 @@ var BABYLON;
             // Attribs
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
             // Values that need to be evaluated on every frame
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
-            if (scene._mirroredCameraPosition && defines.BUMP) {
-                defines.INVERTNORMALMAPX = !this.invertNormalMapX;
-                defines.INVERTNORMALMAPY = !this.invertNormalMapY;
-                defines.markAsUnprocessed();
-            }
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Get correct effect      
             // Get correct effect      
             if (defines.isDirty) {
             if (defines.isDirty) {
                 defines.markAsProcessed();
                 defines.markAsProcessed();
@@ -650,7 +641,7 @@ var BABYLON;
                     "mBones",
                     "mBones",
                     "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
                     "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
                     "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
                     "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
-                    "logarithmicDepthConstant"
+                    "logarithmicDepthConstant", "vTangentSpaceParams"
                 ];
                 ];
                 var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler"];
                 var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler"];
                 var uniformBuffers = ["Material", "Scene"];
                 var uniformBuffers = ["Material", "Scene"];
@@ -680,7 +671,7 @@ var BABYLON;
                 }, engine), defines);
                 }, engine), defines);
                 this.buildUniformLayout();
                 this.buildUniformLayout();
             }
             }
-            if (!subMesh.effect.isReady()) {
+            if (!subMesh.effect || !subMesh.effect.isReady()) {
                 return false;
                 return false;
             }
             }
             defines._renderId = scene.getRenderId();
             defines._renderId = scene.getRenderId();
@@ -714,6 +705,7 @@ var BABYLON;
             this._uniformBuffer.addUniform("lightmapMatrix", 16);
             this._uniformBuffer.addUniform("lightmapMatrix", 16);
             this._uniformBuffer.addUniform("specularMatrix", 16);
             this._uniformBuffer.addUniform("specularMatrix", 16);
             this._uniformBuffer.addUniform("bumpMatrix", 16);
             this._uniformBuffer.addUniform("bumpMatrix", 16);
+            this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
             this._uniformBuffer.addUniform("refractionMatrix", 16);
             this._uniformBuffer.addUniform("refractionMatrix", 16);
             this._uniformBuffer.addUniform("vRefractionInfos", 4);
             this._uniformBuffer.addUniform("vRefractionInfos", 4);
             this._uniformBuffer.addUniform("vSpecularColor", 4);
             this._uniformBuffer.addUniform("vSpecularColor", 4);
@@ -740,6 +732,9 @@ var BABYLON;
                 return;
                 return;
             }
             }
             var effect = subMesh.effect;
             var effect = subMesh.effect;
+            if (!effect) {
+                return;
+            }
             this._activeEffect = effect;
             this._activeEffect = effect;
             // Matrices        
             // Matrices        
             this.bindOnlyWorldMatrix(world);
             this.bindOnlyWorldMatrix(world);
@@ -804,6 +799,12 @@ var BABYLON;
                         if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial_OldVer.BumpTextureEnabled) {
                         if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial_OldVer.BumpTextureEnabled) {
                             this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
                             this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
                             this._uniformBuffer.updateMatrix("bumpMatrix", this._bumpTexture.getTextureMatrix());
                             this._uniformBuffer.updateMatrix("bumpMatrix", this._bumpTexture.getTextureMatrix());
+                            if (scene._mirroredCameraPosition) {
+                                this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
+                            }
+                            else {
+                                this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
+                            }
                         }
                         }
                         if (this._refractionTexture && StandardMaterial_OldVer.RefractionTextureEnabled) {
                         if (this._refractionTexture && StandardMaterial_OldVer.RefractionTextureEnabled) {
                             var depth = 1.0;
                             var depth = 1.0;
@@ -872,7 +873,7 @@ var BABYLON;
                 BABYLON.MaterialHelper.BindClipPlane(effect, scene);
                 BABYLON.MaterialHelper.BindClipPlane(effect, scene);
                 // Colors
                 // Colors
                 scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
                 scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
-                effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.position);
+                BABYLON.MaterialHelper.BindEyePosition(effect, scene);
                 effect.setColor3("vAmbientColor", this._globalAmbientColor);
                 effect.setColor3("vAmbientColor", this._globalAmbientColor);
             }
             }
             if (this._mustRebind(scene, effect) || !this.isFrozen) {
             if (this._mustRebind(scene, effect) || !this.isFrozen) {
@@ -1901,6 +1902,7 @@ vColor=color;\n\
     var StandardShaderVersions = /** @class */ (function () {
     var StandardShaderVersions = /** @class */ (function () {
         function StandardShaderVersions() {
         function StandardShaderVersions() {
         }
         }
+        StandardShaderVersions.Ver3_0 = "3.0.0";
         return StandardShaderVersions;
         return StandardShaderVersions;
     }());
     }());
     BABYLON.StandardShaderVersions = StandardShaderVersions;
     BABYLON.StandardShaderVersions = StandardShaderVersions;
@@ -1947,16 +1949,20 @@ vColor=color;\n\
             return arr;
             return arr;
         };
         };
         CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines) {
         CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines) {
+            var _this = this;
             if (this._isCreatedShader)
             if (this._isCreatedShader)
                 return this._createdShaderName;
                 return this._createdShaderName;
             this._isCreatedShader = false;
             this._isCreatedShader = false;
             CustomMaterial.ShaderIndexer++;
             CustomMaterial.ShaderIndexer++;
-            var name = name + "custom_" + CustomMaterial.ShaderIndexer;
+            var name = "custom_" + CustomMaterial.ShaderIndexer;
             this.ReviewUniform("uniform", uniforms);
             this.ReviewUniform("uniform", uniforms);
             this.ReviewUniform("sampler", samplers);
             this.ReviewUniform("sampler", samplers);
             var fn_afterBind = this._afterBind;
             var fn_afterBind = this._afterBind;
             this._afterBind = function (m, e) {
             this._afterBind = function (m, e) {
-                this.AttachAfterBind(m, e);
+                if (!e) {
+                    return;
+                }
+                _this.AttachAfterBind(m, e);
                 try {
                 try {
                     fn_afterBind(m, e);
                     fn_afterBind(m, e);
                 }
                 }
@@ -1999,7 +2005,7 @@ vColor=color;\n\
                     this._newUniformInstances[kind + "-" + name] = param;
                     this._newUniformInstances[kind + "-" + name] = param;
                 }
                 }
                 else {
                 else {
-                    this._newSamplerInstances[kind + "-" + name] = param;
+                    this._newUniformInstances[kind + "-" + name] = param;
                 }
                 }
             }
             }
             this._customUniform.push("uniform " + kind + " " + name + ";");
             this._customUniform.push("uniform " + kind + " " + name + ";");

File diff suppressed because it is too large
+ 2 - 2
dist/preview release/materialsLibrary/babylon.customMaterial.min.js


+ 23 - 17
dist/preview release/materialsLibrary/babylonjs.materials.js

@@ -4054,15 +4054,12 @@ var BABYLON;
             _this.REFRACTION = false;
             _this.REFRACTION = false;
             _this.REFRACTIONMAP_3D = false;
             _this.REFRACTIONMAP_3D = false;
             _this.REFLECTIONOVERALPHA = false;
             _this.REFLECTIONOVERALPHA = false;
-            _this.INVERTNORMALMAPX = false;
-            _this.INVERTNORMALMAPY = false;
             _this.TWOSIDEDLIGHTING = false;
             _this.TWOSIDEDLIGHTING = false;
             _this.SHADOWFLOAT = false;
             _this.SHADOWFLOAT = false;
             _this.MORPHTARGETS = false;
             _this.MORPHTARGETS = false;
             _this.MORPHTARGETS_NORMAL = false;
             _this.MORPHTARGETS_NORMAL = false;
             _this.MORPHTARGETS_TANGENT = false;
             _this.MORPHTARGETS_TANGENT = false;
             _this.NUM_MORPH_INFLUENCERS = 0;
             _this.NUM_MORPH_INFLUENCERS = 0;
-            _this.USERIGHTHANDEDSYSTEM = false;
             _this.IMAGEPROCESSING = false;
             _this.IMAGEPROCESSING = false;
             _this.VIGNETTE = false;
             _this.VIGNETTE = false;
             _this.VIGNETTEBLENDMODEMULTIPLY = false;
             _this.VIGNETTEBLENDMODEMULTIPLY = false;
@@ -4071,6 +4068,7 @@ var BABYLON;
             _this.CONTRAST = false;
             _this.CONTRAST = false;
             _this.COLORCURVES = false;
             _this.COLORCURVES = false;
             _this.COLORGRADING = false;
             _this.COLORGRADING = false;
+            _this.COLORGRADING3D = false;
             _this.SAMPLER3DGREENDEPTH = false;
             _this.SAMPLER3DGREENDEPTH = false;
             _this.SAMPLER3DBGRMAP = false;
             _this.SAMPLER3DBGRMAP = false;
             _this.IMAGEPROCESSINGPOSTPROCESS = false;
             _this.IMAGEPROCESSINGPOSTPROCESS = false;
@@ -4477,8 +4475,6 @@ var BABYLON;
                         else {
                         else {
                             defines._needUVs = true;
                             defines._needUVs = true;
                             defines.BUMP = true;
                             defines.BUMP = true;
-                            defines.INVERTNORMALMAPX = this.invertNormalMapX;
-                            defines.INVERTNORMALMAPY = this.invertNormalMapY;
                             defines.PARALLAX = this._useParallax;
                             defines.PARALLAX = this._useParallax;
                             defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
                             defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
                         }
                         }
@@ -4547,12 +4543,7 @@ var BABYLON;
             // Attribs
             // Attribs
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
             BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
             // Values that need to be evaluated on every frame
             // Values that need to be evaluated on every frame
-            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
-            if (scene._mirroredCameraPosition && defines.BUMP) {
-                defines.INVERTNORMALMAPX = !this.invertNormalMapX;
-                defines.INVERTNORMALMAPY = !this.invertNormalMapY;
-                defines.markAsUnprocessed();
-            }
+            BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
             // Get correct effect      
             // Get correct effect      
             if (defines.isDirty) {
             if (defines.isDirty) {
                 defines.markAsProcessed();
                 defines.markAsProcessed();
@@ -4629,7 +4620,7 @@ var BABYLON;
                     "mBones",
                     "mBones",
                     "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
                     "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
                     "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
                     "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
-                    "logarithmicDepthConstant"
+                    "logarithmicDepthConstant", "vTangentSpaceParams"
                 ];
                 ];
                 var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler"];
                 var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler"];
                 var uniformBuffers = ["Material", "Scene"];
                 var uniformBuffers = ["Material", "Scene"];
@@ -4659,7 +4650,7 @@ var BABYLON;
                 }, engine), defines);
                 }, engine), defines);
                 this.buildUniformLayout();
                 this.buildUniformLayout();
             }
             }
-            if (!subMesh.effect.isReady()) {
+            if (!subMesh.effect || !subMesh.effect.isReady()) {
                 return false;
                 return false;
             }
             }
             defines._renderId = scene.getRenderId();
             defines._renderId = scene.getRenderId();
@@ -4693,6 +4684,7 @@ var BABYLON;
             this._uniformBuffer.addUniform("lightmapMatrix", 16);
             this._uniformBuffer.addUniform("lightmapMatrix", 16);
             this._uniformBuffer.addUniform("specularMatrix", 16);
             this._uniformBuffer.addUniform("specularMatrix", 16);
             this._uniformBuffer.addUniform("bumpMatrix", 16);
             this._uniformBuffer.addUniform("bumpMatrix", 16);
+            this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
             this._uniformBuffer.addUniform("refractionMatrix", 16);
             this._uniformBuffer.addUniform("refractionMatrix", 16);
             this._uniformBuffer.addUniform("vRefractionInfos", 4);
             this._uniformBuffer.addUniform("vRefractionInfos", 4);
             this._uniformBuffer.addUniform("vSpecularColor", 4);
             this._uniformBuffer.addUniform("vSpecularColor", 4);
@@ -4719,6 +4711,9 @@ var BABYLON;
                 return;
                 return;
             }
             }
             var effect = subMesh.effect;
             var effect = subMesh.effect;
+            if (!effect) {
+                return;
+            }
             this._activeEffect = effect;
             this._activeEffect = effect;
             // Matrices        
             // Matrices        
             this.bindOnlyWorldMatrix(world);
             this.bindOnlyWorldMatrix(world);
@@ -4783,6 +4778,12 @@ var BABYLON;
                         if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial_OldVer.BumpTextureEnabled) {
                         if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial_OldVer.BumpTextureEnabled) {
                             this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
                             this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
                             this._uniformBuffer.updateMatrix("bumpMatrix", this._bumpTexture.getTextureMatrix());
                             this._uniformBuffer.updateMatrix("bumpMatrix", this._bumpTexture.getTextureMatrix());
+                            if (scene._mirroredCameraPosition) {
+                                this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
+                            }
+                            else {
+                                this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
+                            }
                         }
                         }
                         if (this._refractionTexture && StandardMaterial_OldVer.RefractionTextureEnabled) {
                         if (this._refractionTexture && StandardMaterial_OldVer.RefractionTextureEnabled) {
                             var depth = 1.0;
                             var depth = 1.0;
@@ -4851,7 +4852,7 @@ var BABYLON;
                 BABYLON.MaterialHelper.BindClipPlane(effect, scene);
                 BABYLON.MaterialHelper.BindClipPlane(effect, scene);
                 // Colors
                 // Colors
                 scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
                 scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
-                effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.position);
+                BABYLON.MaterialHelper.BindEyePosition(effect, scene);
                 effect.setColor3("vAmbientColor", this._globalAmbientColor);
                 effect.setColor3("vAmbientColor", this._globalAmbientColor);
             }
             }
             if (this._mustRebind(scene, effect) || !this.isFrozen) {
             if (this._mustRebind(scene, effect) || !this.isFrozen) {
@@ -5880,6 +5881,7 @@ vColor=color;\n\
     var StandardShaderVersions = /** @class */ (function () {
     var StandardShaderVersions = /** @class */ (function () {
         function StandardShaderVersions() {
         function StandardShaderVersions() {
         }
         }
+        StandardShaderVersions.Ver3_0 = "3.0.0";
         return StandardShaderVersions;
         return StandardShaderVersions;
     }());
     }());
     BABYLON.StandardShaderVersions = StandardShaderVersions;
     BABYLON.StandardShaderVersions = StandardShaderVersions;
@@ -5926,16 +5928,20 @@ vColor=color;\n\
             return arr;
             return arr;
         };
         };
         CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines) {
         CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines) {
+            var _this = this;
             if (this._isCreatedShader)
             if (this._isCreatedShader)
                 return this._createdShaderName;
                 return this._createdShaderName;
             this._isCreatedShader = false;
             this._isCreatedShader = false;
             CustomMaterial.ShaderIndexer++;
             CustomMaterial.ShaderIndexer++;
-            var name = name + "custom_" + CustomMaterial.ShaderIndexer;
+            var name = "custom_" + CustomMaterial.ShaderIndexer;
             this.ReviewUniform("uniform", uniforms);
             this.ReviewUniform("uniform", uniforms);
             this.ReviewUniform("sampler", samplers);
             this.ReviewUniform("sampler", samplers);
             var fn_afterBind = this._afterBind;
             var fn_afterBind = this._afterBind;
             this._afterBind = function (m, e) {
             this._afterBind = function (m, e) {
-                this.AttachAfterBind(m, e);
+                if (!e) {
+                    return;
+                }
+                _this.AttachAfterBind(m, e);
                 try {
                 try {
                     fn_afterBind(m, e);
                     fn_afterBind(m, e);
                 }
                 }
@@ -5978,7 +5984,7 @@ vColor=color;\n\
                     this._newUniformInstances[kind + "-" + name] = param;
                     this._newUniformInstances[kind + "-" + name] = param;
                 }
                 }
                 else {
                 else {
-                    this._newSamplerInstances[kind + "-" + name] = param;
+                    this._newUniformInstances[kind + "-" + name] = param;
                 }
                 }
             }
             }
             this._customUniform.push("uniform " + kind + " " + name + ";");
             this._customUniform.push("uniform " + kind + " " + name + ";");

File diff suppressed because it is too large
+ 3 - 3
dist/preview release/materialsLibrary/babylonjs.materials.min.js


+ 4 - 6
dist/preview release/materialsLibrary/babylonjs.materials.module.d.ts

@@ -558,15 +558,12 @@ declare module BABYLON {
         REFRACTION: boolean;
         REFRACTION: boolean;
         REFRACTIONMAP_3D: boolean;
         REFRACTIONMAP_3D: boolean;
         REFLECTIONOVERALPHA: boolean;
         REFLECTIONOVERALPHA: boolean;
-        INVERTNORMALMAPX: boolean;
-        INVERTNORMALMAPY: boolean;
         TWOSIDEDLIGHTING: boolean;
         TWOSIDEDLIGHTING: boolean;
         SHADOWFLOAT: boolean;
         SHADOWFLOAT: boolean;
         MORPHTARGETS: boolean;
         MORPHTARGETS: boolean;
         MORPHTARGETS_NORMAL: boolean;
         MORPHTARGETS_NORMAL: boolean;
         MORPHTARGETS_TANGENT: boolean;
         MORPHTARGETS_TANGENT: boolean;
         NUM_MORPH_INFLUENCERS: number;
         NUM_MORPH_INFLUENCERS: number;
-        USERIGHTHANDEDSYSTEM: boolean;
         IMAGEPROCESSING: boolean;
         IMAGEPROCESSING: boolean;
         VIGNETTE: boolean;
         VIGNETTE: boolean;
         VIGNETTEBLENDMODEMULTIPLY: boolean;
         VIGNETTEBLENDMODEMULTIPLY: boolean;
@@ -575,6 +572,7 @@ declare module BABYLON {
         CONTRAST: boolean;
         CONTRAST: boolean;
         COLORCURVES: boolean;
         COLORCURVES: boolean;
         COLORGRADING: boolean;
         COLORGRADING: boolean;
+        COLORGRADING3D: boolean;
         SAMPLER3DGREENDEPTH: boolean;
         SAMPLER3DGREENDEPTH: boolean;
         SAMPLER3DBGRMAP: boolean;
         SAMPLER3DBGRMAP: boolean;
         IMAGEPROCESSINGPOSTPROCESS: boolean;
         IMAGEPROCESSINGPOSTPROCESS: boolean;
@@ -681,7 +679,7 @@ declare module BABYLON {
          * Attaches a new image processing configuration to the Standard Material.
          * Attaches a new image processing configuration to the Standard Material.
          * @param configuration
          * @param configuration
          */
          */
-        protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration): void;
+        protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
         /**
         /**
          * Gets wether the color curves effect is enabled.
          * Gets wether the color curves effect is enabled.
          */
          */
@@ -727,7 +725,7 @@ declare module BABYLON {
         /**
         /**
          * Sets the Color Grading 2D Lookup Texture.
          * Sets the Color Grading 2D Lookup Texture.
          */
          */
-        cameraColorGradingTexture: BaseTexture;
+        cameraColorGradingTexture: Nullable<BaseTexture>;
         customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines_OldVer) => string;
         customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines_OldVer) => string;
         protected _renderTargets: SmartArray<RenderTargetTexture>;
         protected _renderTargets: SmartArray<RenderTargetTexture>;
         protected _worldViewProjectionMatrix: Matrix;
         protected _worldViewProjectionMatrix: Matrix;
@@ -799,7 +797,7 @@ declare module BABYLON {
         constructor();
         constructor();
     }
     }
     class StandardShaderVersions {
     class StandardShaderVersions {
-        static Ver3_0: any;
+        static Ver3_0: string;
     }
     }
     class CustomMaterial extends StandardMaterial_OldVer {
     class CustomMaterial extends StandardMaterial_OldVer {
         static ShaderIndexer: number;
         static ShaderIndexer: number;

+ 6 - 0
gui/src/advancedDynamicTexture.ts

@@ -115,10 +115,16 @@ module BABYLON.GUI {
         }
         }
         
         
         public get isForeground(): boolean {
         public get isForeground(): boolean {
+            if (!this.layer) {
+                return true;
+            }
             return (!this.layer.isBackground);
             return (!this.layer.isBackground);
         }
         }
 
 
         public set isForeground(value: boolean) {
         public set isForeground(value: boolean) {
+            if (!this.layer) {
+                return;
+            }            
             if (this.layer.isBackground === !value) {
             if (this.layer.isBackground === !value) {
                 return;
                 return;
             }
             }