فهرست منبع

rewrited uniformBuffer class for avoiding boolean tests and fixed default fragment declaration for bumpInfos

Benjamin Guignabert 8 سال پیش
والد
کامیت
3b28295b66

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3933 - 3910
dist/preview release/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3933 - 3910
dist/preview release/babylon.module.d.ts


+ 17 - 19
dist/preview release/materialsLibrary/babylon.gradientMaterial.js

@@ -155,29 +155,27 @@ var BABYLON;
                 // Legacy browser patch
                 var shaderName = "gradient";
                 var join = defines.toString();
+                var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
+                    "vFogInfos", "vFogColor", "pointSize",
+                    "vDiffuseInfos",
+                    "mBones",
+                    "vClipPlane", "diffuseMatrix",
+                    "depthValues", "topColor", "bottomColor", "offset", "smoothness"
+                ];
+                var samplers = ["diffuseSampler"];
                 var uniformBuffers = [];
-                for (var i = 0; i < 4; i++) {
-                    if (defines["LIGHT" + i]) {
-                        uniformBuffers.push("Light" + i);
-                    }
-                }
+                BABYLON.MaterialHelper.PrepareUniformsAndSamplersList({
+                    uniformsNames: uniforms,
+                    uniformBuffersNames: uniformBuffers,
+                    samplers: samplers,
+                    defines: defines,
+                    maxSimultaneousLights: 4
+                });
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
                     attributes: attribs,
-                    uniformsNames: ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
-                        "vLightData0", "vLightDiffuse0", "vLightDirection0", "vLightGround0", "lightMatrix0",
-                        "vLightData1", "vLightDiffuse1", "vLightDirection1", "vLightGround1", "lightMatrix1",
-                        "vLightData2", "vLightDiffuse2", "vLightDirection2", "vLightGround2", "lightMatrix2",
-                        "vLightData3", "vLightDiffuse3", "vLightDirection3", "vLightGround3", "lightMatrix3",
-                        "vFogInfos", "vFogColor", "pointSize",
-                        "vDiffuseInfos",
-                        "mBones",
-                        "vClipPlane", "diffuseMatrix",
-                        "shadowsInfo0", "shadowsInfo1", "shadowsInfo2", "shadowsInfo3", "depthValues", "topColor", "bottomColor", "offset", "smoothness"
-                    ],
+                    uniformsNames: uniforms,
                     uniformBuffersNames: uniformBuffers,
-                    samplers: ["diffuseSampler",
-                        "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3"
-                    ],
+                    samplers: samplers,
                     defines: join,
                     fallbacks: fallbacks,
                     onCompiled: this.onCompiled,

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/preview release/materialsLibrary/babylon.gradientMaterial.min.js


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

@@ -170,31 +170,31 @@ var BABYLON;
                 // Legacy browser patch
                 var shaderName = "lava";
                 var join = defines.toString();
+                var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
+                    "vFogInfos", "vFogColor", "pointSize",
+                    "vDiffuseInfos",
+                    "mBones",
+                    "vClipPlane", "diffuseMatrix",
+                    "depthValues",
+                    "time", "speed", "movingSpeed",
+                    "fogColor", "fogDensity", "lowFrequencySpeed"
+                ];
+                var samplers = ["diffuseSampler",
+                    "noiseTexture"
+                ];
                 var uniformBuffers = [];
-                for (var i = 0; i < this.maxSimultaneousLights; i++) {
-                    if (defines["LIGHT" + i]) {
-                        uniformBuffers.push("Light" + i);
-                    }
-                }
+                BABYLON.MaterialHelper.PrepareUniformsAndSamplersList({
+                    uniformsNames: uniforms,
+                    uniformBuffersNames: uniformBuffers,
+                    samplers: samplers,
+                    defines: defines,
+                    maxSimultaneousLights: this.maxSimultaneousLights
+                });
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
                     attributes: attribs,
-                    uniformsNames: ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
-                        "vLightData0", "vLightDiffuse0", "vLightDirection0", "vLightGround0", "lightMatrix0",
-                        "vLightData1", "vLightDiffuse1", "vLightDirection1", "vLightGround1", "lightMatrix1",
-                        "vLightData2", "vLightDiffuse2", "vLightDirection2", "vLightGround2", "lightMatrix2",
-                        "vLightData3", "vLightDiffuse3", "vLightDirection3", "vLightGround3", "lightMatrix3",
-                        "vFogInfos", "vFogColor", "pointSize",
-                        "vDiffuseInfos",
-                        "mBones",
-                        "vClipPlane", "diffuseMatrix",
-                        "shadowsInfo0", "shadowsInfo1", "shadowsInfo2", "shadowsInfo3", "depthValues",
-                        "time", "speed", "movingSpeed",
-                        "fogColor", "fogDensity", "lowFrequencySpeed"
-                    ],
+                    uniformsNames: uniforms,
                     uniformBuffersNames: uniformBuffers,
-                    samplers: ["diffuseSampler",
-                        "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3", "noiseTexture"
-                    ],
+                    samplers: samplers,
                     defines: join,
                     fallbacks: fallbacks,
                     onCompiled: this.onCompiled,

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/preview release/materialsLibrary/babylon.lavaMaterial.min.js


+ 17 - 19
dist/preview release/materialsLibrary/babylon.normalMaterial.js

@@ -164,29 +164,27 @@ var BABYLON;
                 BABYLON.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
                 var shaderName = "normal";
                 var join = defines.toString();
+                var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
+                    "vFogInfos", "vFogColor", "pointSize",
+                    "vDiffuseInfos",
+                    "mBones",
+                    "vClipPlane", "diffuseMatrix",
+                    "depthValues"
+                ];
+                var samplers = ["diffuseSampler"];
                 var uniformBuffers = [];
-                for (var i = 0; i < 4; i++) {
-                    if (defines["LIGHT" + i]) {
-                        uniformBuffers.push("Light" + i);
-                    }
-                }
+                BABYLON.MaterialHelper.PrepareUniformsAndSamplersList({
+                    uniformsNames: uniforms,
+                    uniformBuffersNames: uniformBuffers,
+                    samplers: samplers,
+                    defines: defines,
+                    maxSimultaneousLights: 4
+                });
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
                     attributes: attribs,
-                    uniformsNames: ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
-                        "vLightData0", "vLightDiffuse0", "vLightDirection0", "vLightGround0", "lightMatrix0",
-                        "vLightData1", "vLightDiffuse1", "vLightDirection1", "vLightGround1", "lightMatrix1",
-                        "vLightData2", "vLightDiffuse2", "vLightDirection2", "vLightGround2", "lightMatrix2",
-                        "vLightData3", "vLightDiffuse3", "vLightDirection3", "vLightGround3", "lightMatrix3",
-                        "vFogInfos", "vFogColor", "pointSize",
-                        "vDiffuseInfos",
-                        "mBones",
-                        "vClipPlane", "diffuseMatrix",
-                        "shadowsInfo0", "shadowsInfo1", "shadowsInfo2", "shadowsInfo3", "depthValues"
-                    ],
+                    uniformsNames: uniforms,
                     uniformBuffersNames: uniformBuffers,
-                    samplers: ["diffuseSampler",
-                        "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3"
-                    ],
+                    samplers: samplers,
                     defines: join,
                     fallbacks: fallbacks,
                     onCompiled: this.onCompiled,

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/preview release/materialsLibrary/babylon.normalMaterial.min.js


+ 1 - 1
src/Lights/babylon.directionalLight.ts

@@ -174,7 +174,7 @@ module BABYLON {
          * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.  
          * Returns the DirectionalLight.  
          */
-        public transferToEffect(effect: Effect, lightIndex: number): DirectionalLight {
+        public transferToEffect(effect: Effect, lightIndex: string): DirectionalLight {
             if (this.parent && this.parent.getWorldMatrix) {
                 if (!this._transformedDirection) {
                     this._transformedDirection = Vector3.Zero();

+ 1 - 1
src/Lights/babylon.hemisphericLight.ts

@@ -51,7 +51,7 @@
          * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).  
          * Returns the HemisphericLight.  
          */
-        public transferToEffect(effect: Effect, lightIndex: number): HemisphericLight {
+        public transferToEffect(effect: Effect, lightIndex: string): HemisphericLight {
             var normalizeDirection = Vector3.Normalize(this.direction);
             this._uniformBuffer.updateFloat4("vLightData",
                 normalizeDirection.x,

+ 1 - 1
src/Lights/babylon.light.ts

@@ -207,7 +207,7 @@
             return Vector3.Zero();
         }
 
-        public transferToEffect(effect: Effect, lightIndex: number): void {
+        public transferToEffect(effect: Effect, lightIndex: string): void {
         }
 
         public _getWorldMatrix(): Matrix {

+ 1 - 1
src/Lights/babylon.pointLight.ts

@@ -69,7 +69,7 @@
          * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).  
          * Returns the PointLight.  
          */
-        public transferToEffect(effect: Effect, lightIndex: number): PointLight {
+        public transferToEffect(effect: Effect, lightIndex: string): PointLight {
 
             if (this.parent && this.parent.getWorldMatrix) {
                 this.computeTransformedPosition();

+ 1 - 1
src/Lights/babylon.spotLight.ts

@@ -129,7 +129,7 @@
          * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.  
          * Return the SpotLight.   
          */
-        public transferToEffect(effect: Effect, lightIndex: number): SpotLight {
+        public transferToEffect(effect: Effect, lightIndex: string): SpotLight {
             var normalizeDirection;
 
             if (this.parent && this.parent.getWorldMatrix) {

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

@@ -303,7 +303,7 @@
         }
 
         // Bindings
-        public static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: number, effect: Effect, depthValuesAlreadySet: boolean): boolean {
+        public static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect, depthValuesAlreadySet: boolean): boolean {
             var shadowGenerator = <ShadowGenerator>light.getShadowGenerator();
 
             if (mesh.receiveShadows && shadowGenerator) {
@@ -323,7 +323,7 @@
         }
 
         public static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void {
-            light.transferToEffect(effect, lightIndex);
+            light.transferToEffect(effect, lightIndex + "");
         }
 
         public static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights = 4) {
@@ -336,15 +336,15 @@
                 MaterialHelper.BindLightProperties(light, effect, lightIndex);
 
                 light.diffuse.scaleToRef(light.intensity, Tmp.Color3[0]);
-                light._uniformBuffer.updateColor4("vLightDiffuse", Tmp.Color3[0], light.range, lightIndex);
+                light._uniformBuffer.updateColor4("vLightDiffuse", Tmp.Color3[0], light.range, lightIndex + "");
                 if (defines["SPECULARTERM"]) {
                     light.specular.scaleToRef(light.intensity, Tmp.Color3[1]);
-                    light._uniformBuffer.updateColor3("vLightSpecular", Tmp.Color3[1], lightIndex);
+                    light._uniformBuffer.updateColor3("vLightSpecular", Tmp.Color3[1], lightIndex + "");
                 }
 
                 // Shadows
                 if (scene.shadowsEnabled) {
-                    depthValuesAlreadySet = this.BindLightShadow(light, scene, mesh, lightIndex, effect, depthValuesAlreadySet);
+                    depthValuesAlreadySet = this.BindLightShadow(light, scene, mesh, lightIndex + "", effect, depthValuesAlreadySet);
                 }
                 light._uniformBuffer.update();
                 lightIndex++;

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

@@ -655,7 +655,7 @@
 
                 // Shadows
                 if (scene.shadowsEnabled) {
-                    depthValuesAlreadySet = MaterialHelper.BindLightShadow(light, scene, mesh, lightIndex, effect, depthValuesAlreadySet);
+                    depthValuesAlreadySet = MaterialHelper.BindLightShadow(light, scene, mesh, lightIndex + "", effect, depthValuesAlreadySet);
                 }
 
                 light._uniformBuffer.update();

+ 167 - 144
src/Materials/babylon.uniformBuffer.ts

@@ -20,6 +20,95 @@ module BABYLON {
         private static _tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
 
         /**
+         * Wrapper for updateUniform.
+         * @method updateMatrix3x3 
+         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * @param {Float32Array} matrix
+         */
+        public updateMatrix3x3: (name: string, matrix: Float32Array) => void;
+
+        /**
+         * Wrapper for updateUniform.
+         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * @param {Float32Array} matrix
+         */
+        public updateMatrix2x2: (name: string, matrix: Float32Array) => void;
+
+        /**
+         * Wrapper for updateUniform.
+         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * @param {number} x
+         */
+        public updateFloat: (name: string, x: number) => void;
+
+        /**
+         * Wrapper for updateUniform.
+         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * @param {number} x
+         * @param {number} y
+         */
+        public updateFloat2: (name: string, x: number, y: number) => void;
+
+        /**
+         * Wrapper for updateUniform.
+         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * @param {number} x
+         * @param {number} y
+         * @param {number} z
+         * @param {string} [suffix] Suffix to add to the uniform name.
+         */
+        public updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
+
+        /**
+         * Wrapper for updateUniform.
+         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * @param {number} x
+         * @param {number} y
+         * @param {number} z
+         * @param {number} w
+         * @param {string} [suffix] Suffix to add to the uniform name.
+         */
+        public updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
+
+        /**
+         * Wrapper for updateUniform.
+         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * @param {Matrix} A 4x4 matrix.
+         */
+        public updateMatrix: (name: string, mat: Matrix) => void;
+
+        /**
+         * Wrapper for updateUniform.
+         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * @param {Vector3} vector
+         */
+        public updateVector3: (name: string, vector: Vector3) => void;
+
+        /**
+         * Wrapper for updateUniform.
+         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * @param {Vector4} vector
+         */
+        public updateVector4: (name: string, vector: Vector4) => void;
+
+        /**
+         * Wrapper for updateUniform.
+         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * @param {Color3} color
+         * @param {string} [suffix] Suffix to add to the uniform name.
+         */
+        public updateColor3: (name: string, color: Color3, suffix?: string) => void;
+
+        /**
+         * Wrapper for updateUniform.
+         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * @param {Color3} color
+         * @param {number} alpha
+         * @param {string} [suffix] Suffix to add to the uniform name.
+         */
+        public updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
+
+        /**
          * Uniform buffer objects.
          * 
          * Handles blocks of uniform on the GPU.
@@ -41,6 +130,32 @@ module BABYLON {
             this._uniformLocationPointer = 0;
             this._needSync = false;
 
+            if (this._noUBO) {
+                this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
+                this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
+                this.updateFloat = this._updateFloatForEffect;
+                this.updateFloat2 = this._updateFloat2ForEffect;
+                this.updateFloat3 = this._updateFloat3ForEffect;
+                this.updateFloat4 = this._updateFloat4ForEffect;
+                this.updateMatrix = this._updateMatrixForEffect;
+                this.updateVector3 = this._updateVector3ForEffect;
+                this.updateVector4 = this._updateVector4ForEffect;
+                this.updateColor3 = this._updateColor3ForEffect;
+                this.updateColor4 = this._updateColor4ForEffect;
+            } else {
+                this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
+                this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
+                this.updateFloat = this._updateFloatForUniform;
+                this.updateFloat2 = this._updateFloat2ForUniform;
+                this.updateFloat3 = this._updateFloat3ForUniform;
+                this.updateFloat4 = this._updateFloat4ForUniform;
+                this.updateMatrix = this._updateMatrixForUniform;
+                this.updateVector3 = this._updateVector3ForUniform;
+                this.updateVector4 = this._updateVector4ForUniform;
+                this.updateColor3 = this._updateColor3ForUniform;
+                this.updateColor4 = this._updateColor4ForUniform;
+            }
+
         }
 
         // Properties
@@ -324,19 +439,9 @@ module BABYLON {
             }
         }
 
-        /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Float32Array} matrix
-         */
-        public updateMatrix3x3(name: string, matrix: Float32Array): Effect {
-            if (this._noUBO) {
-                if (this._currentEffect) {
-                    this._currentEffect.setMatrix3x3(name, matrix);
-                }
-                return;
-            }
+        // Update methods
 
+        private _updateMatrix3x3ForUniform(name: string, matrix: Float32Array): void {
             // To match std140, matrix must be realigned
             for (var i = 0; i < 3; i++) {
                 UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
@@ -348,19 +453,15 @@ module BABYLON {
             this.updateUniform(name, UniformBuffer._tempBuffer, 12);
         }
 
-        /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Float32Array} matrix
-         */
-        public updateMatrix2x2(name: string, matrix: Float32Array): Effect {
-            if (this._noUBO) {
-                if (this._currentEffect) {
-                    this._currentEffect.setMatrix2x2(name, matrix);
-                }
-                return;
-            }
+        private _updateMatrix3x3ForEffect(name: string, matrix: Float32Array): void {
+            this._currentEffect.setMatrix3x3(name, matrix);
+        }
+
+        private _updateMatrix2x2ForEffect(name: string, matrix: Float32Array): void {
+            this._currentEffect.setMatrix2x2(name, matrix);
+        }
 
+        private _updateMatrix2x2ForUniform(name: string, matrix: Float32Array): void {
             // To match std140, matrix must be realigned
             for (var i = 0; i < 2; i++) {
                 UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
@@ -372,81 +473,42 @@ module BABYLON {
             this.updateUniform(name, UniformBuffer._tempBuffer, 8);
         }
 
-        /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {number} x
-         */
-        public updateFloat(name: string, x: number) {
-            if (this._noUBO) {
-                if (this._currentEffect) {
-                    this._currentEffect.setFloat(name, x);
-                }
-                return;
-            }
+        private _updateFloatForEffect(name: string, x: number) {
+            this._currentEffect.setFloat(name, x);
+        }
 
+        private _updateFloatForUniform(name: string, x: number) {
             UniformBuffer._tempBuffer[0] = x;
             this.updateUniform(name, UniformBuffer._tempBuffer, 1);
         }
 
-        /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {number} x
-         * @param {number} y
-         */
-        public updateFloat2(name: string, x: number, y: number) {
-            if (this._noUBO) {
-                if (this._currentEffect) {
-                    this._currentEffect.setFloat2(name, x, y);
-                }
-                return;
-            }
+        private _updateFloat2ForEffect(name: string, x: number, y: number) {
+            this._currentEffect.setFloat2(name, x, y);
+        }
 
+        private _updateFloat2ForUniform(name: string, x: number, y: number) {
             UniformBuffer._tempBuffer[0] = x;
             UniformBuffer._tempBuffer[1] = y;
             this.updateUniform(name, UniformBuffer._tempBuffer, 2);
-        }
+        }        
 
-        /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {number} x
-         * @param {number} y
-         * @param {number} z
-         * @param {string|number} [suffix] Suffix to add to the uniform name.
-         */
-        public updateFloat3(name: string, x: number, y: number, z: number, suffix?: string | number) {
-            if (this._noUBO) {
-                if (this._currentEffect) {
-                    this._currentEffect.setFloat3(name + suffix, x, y, z);
-                }
-                return;
-            }
+        private _updateFloat3ForEffect(name: string, x: number, y: number, z: number, suffix = "") {
+            this._currentEffect.setFloat3(name + suffix, x, y, z);
+        }
 
+        private _updateFloat3ForUniform(name: string, x: number, y: number, z: number, suffix = "") {
             UniformBuffer._tempBuffer[0] = x;
             UniformBuffer._tempBuffer[1] = y;
             UniformBuffer._tempBuffer[2] = z;
             this.updateUniform(name, UniformBuffer._tempBuffer, 3);
+
         }
 
-        /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {number} x
-         * @param {number} y
-         * @param {number} z
-         * @param {number} w
-         * @param {string|number} [suffix] Suffix to add to the uniform name.
-         */
-        public updateFloat4(name: string, x: number, y: number, z: number, w: number, suffix?: string | number) {
-            if (this._noUBO) {
-                if (this._currentEffect) {
-                    this._currentEffect.setFloat4(name + suffix, x, y, z, w);
-                }
-                return;
-            }
+        private _updateFloat4ForEffect(name: string, x: number, y: number, z: number, w: number, suffix = "") {
+            this._currentEffect.setFloat4(name + suffix, x, y, z, w);
+        }
 
+        private _updateFloat4ForUniform(name: string, x: number, y: number, z: number, w: number, suffix = "") {
             UniformBuffer._tempBuffer[0] = x;
             UniformBuffer._tempBuffer[1] = y;
             UniformBuffer._tempBuffer[2] = z;
@@ -454,85 +516,46 @@ module BABYLON {
             this.updateUniform(name, UniformBuffer._tempBuffer, 4);
         }
 
-        /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Matrix} A 4x4 matrix.
-         */
-        public updateMatrix(name: string, mat: Matrix) {
-            if (this._noUBO) {
-                if (this._currentEffect) {
-                    this._currentEffect.setMatrix(name, mat);
-                }
-                return;
-            }
+        private _updateMatrixForEffect(name: string, mat: Matrix) {
+            this._currentEffect.setMatrix(name, mat);
+        }
 
+        private _updateMatrixForUniform(name: string, mat: Matrix) {
             this.updateUniform(name, mat.toArray(), 16);
         }
 
-        /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Vector3} vector
-         */
-        public updateVector3(name: string, vector: Vector3) {
-            if (this._noUBO) {
-                if (this._currentEffect) {
-                    this._currentEffect.setVector3(name, vector);
-                }
-                return;
-            }
+        private _updateVector3ForEffect(name: string, vector: Vector3) {
+            this._currentEffect.setVector3(name, vector);
+        }
+
+        private _updateVector3ForUniform(name: string, vector: Vector3) {
             vector.toArray(UniformBuffer._tempBuffer);
             this.updateUniform(name, UniformBuffer._tempBuffer, 3);
         }
 
-        /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Vector4} vector
-         */
-        public updateVector4(name: string, vector: Vector4) {
-            if (this._noUBO) {
-                if (this._currentEffect) {
-                    this._currentEffect.setVector4(name, vector);
-                }
-                return;
-            }
+        private _updateVector4ForEffect(name: string, vector: Vector4) {
+            this._currentEffect.setVector4(name, vector);
+        }
+
+        private _updateVector4ForUniform(name: string, vector: Vector4) {
             vector.toArray(UniformBuffer._tempBuffer);
             this.updateUniform(name, UniformBuffer._tempBuffer, 4);
         }
 
-        /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Color3} color
-         * @param {string|number} [suffix] Suffix to add to the uniform name.
-         */
-        public updateColor3(name: string, color: Color3, suffix?: string | number) {
-            if (this._noUBO) {
-                if (this._currentEffect) {
-                    this._currentEffect.setColor3(name + suffix, color);
-                }
-                return;
-            }
+        private _updateColor3ForEffect(name: string, color: Color3, suffix = "") {
+            this._currentEffect.setColor3(name + suffix, color);
+        }
+
+        private _updateColor3ForUniform(name: string, color: Color3, suffix = "") {
             color.toArray(UniformBuffer._tempBuffer);
             this.updateUniform(name, UniformBuffer._tempBuffer, 3);
         }
 
-        /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Color3} color
-         * @param {number} alpha
-         * @param {string|number} [suffix] Suffix to add to the uniform name.
-         */
-        public updateColor4(name: string, color: Color3, alpha: number, suffix?: string | number) {
-            if (this._noUBO) {
-                if (this._currentEffect) {
-                    this._currentEffect.setColor4(name + suffix, color, alpha);
-                }
-                return;
-            }
+        private _updateColor4ForEffect(name: string, color: Color3, alpha: number, suffix = "") {
+            this._currentEffect.setColor4(name + suffix, color, alpha);
+        }
+
+        private _updateColor4ForUniform(name: string, color: Color3, alpha: number, suffix = "") {
             color.toArray(UniformBuffer._tempBuffer);
             UniformBuffer._tempBuffer[3] = alpha;
             this.updateUniform(name, UniformBuffer._tempBuffer, 4);

+ 4 - 0
src/Shaders/ShadersInclude/defaultFragmentDeclaration.fx

@@ -25,6 +25,10 @@ uniform vec2 vEmissiveInfos;
 uniform vec2 vLightmapInfos;
 #endif
 
+#ifdef BUMP
+uniform vec3 vBumpInfos;
+#endif
+
 #if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
 uniform mat4 view;
 #endif