Sfoglia il codice sorgente

adding uniformBuffersList to effect constructor

Benjamin Guignabert 8 anni fa
parent
commit
5d6df9a3a5

File diff suppressed because it is too large
+ 28 - 28
dist/preview release/babylon.core.js


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


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


File diff suppressed because it is too large
+ 539 - 92
dist/preview release/babylon.max.js


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


File diff suppressed because it is too large
+ 40 - 40
dist/preview release/babylon.noworker.js


+ 2 - 0
src/Layer/babylon.highlightlayer.ts

@@ -299,6 +299,7 @@ module BABYLON {
             this._glowMapMergeEffect = engine.createEffect("glowMapMerge",
                 [VertexBuffer.PositionKind],
                 ["offset"],
+                [],
                 ["textureSampler"], "");
 
             // Render target
@@ -582,6 +583,7 @@ module BABYLON {
                 this._glowMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration",
                     attribs,
                     ["world", "mBones", "viewProjection", "diffuseMatrix", "color", "emissiveMatrix"],
+                    [],
                     ["diffuseSampler", "emissiveSampler"], join);
             }
 

+ 2 - 0
src/Layer/babylon.layer.ts

@@ -95,11 +95,13 @@
             this._effect = engine.createEffect("layer",
                 [VertexBuffer.PositionKind],
                 ["textureMatrix", "color", "scale", "offset"],
+                [],
                 ["textureSampler"], "");
 
             this._alphaTestEffect = engine.createEffect("layer",
                 [VertexBuffer.PositionKind],
                 ["textureMatrix", "color", "scale", "offset"],
+                [],
                 ["textureSampler"], "#define ALPHATEST");
         }
 

+ 1 - 0
src/LensFlare/babylon.lensFlareSystem.ts

@@ -52,6 +52,7 @@
             this._effect = engine.createEffect("lensFlare",
                 [VertexBuffer.PositionKind],
                 ["color", "viewportMatrix"],
+                [],
                 ["textureSampler"], "");
         }
 

+ 1 - 0
src/Lights/Shadows/babylon.shadowGenerator.ts

@@ -394,6 +394,7 @@
                 this._effect = this._scene.getEngine().createEffect("shadowMap",
                     attribs,
                     ["world", "mBones", "viewProjection", "diffuseMatrix", "lightPosition", "depthValues", "biasAndScale"],
+                    [],
                     ["diffuseSampler"], join);
             }
 

+ 1 - 0
src/Materials/Textures/Procedurals/babylon.proceduralTexture.ts

@@ -107,6 +107,7 @@
             this._effect = engine.createEffect(shaders,
                 [VertexBuffer.PositionKind],
                 this._uniforms,
+                [],
                 this._samplers,
                 "", null, null, () => {
                     this.releaseInternalTexture();

+ 2 - 3
src/Materials/babylon.effect.ts

@@ -96,12 +96,11 @@
         private _program: WebGLProgram;
         private _valueCache: { [key: string]: any } = {};
 
-        constructor(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any) {
+        constructor(baseName: any, attributesNames: string[], uniformsNames: string[], uniformBuffers: string[], samplers: string[], engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any) {
             this._engine = engine;
             this.name = baseName;
             this.defines = defines;
-            // TODO
-            this._uniformBuffersNames = ["Material", "Light0", "Scene"];
+            this._uniformBuffersNames = uniformBuffers;
 
             this._uniformsNames = uniformsNames.concat(samplers);
             this._samplers = samplers;

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

@@ -187,21 +187,16 @@
             return needNormals;
         }
 
-        public static PrepareUniformsAndSamplersList(uniformsList: string[], samplersList: string[], defines: MaterialDefines, maxSimultaneousLights = 4): void {
+        public static PrepareUniformsAndSamplersList(uniformsList: string[], uniformBuffersList: string[], samplersList: string[], defines: MaterialDefines, maxSimultaneousLights = 4): void {
             for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
                 if (!defines["LIGHT" + lightIndex]) {
                     break;
                 }
 
                 uniformsList.push(
-                    "vLightData" + lightIndex,
-                    "vLightDiffuse" + lightIndex,
-                    "vLightSpecular" + lightIndex,
-                    "vLightDirection" + lightIndex,
-                    "vLightGround" + lightIndex,
-                    "lightMatrix" + lightIndex,
-                    "shadowsInfo" + lightIndex
+                    "lightMatrix" + lightIndex
                 );
+                uniformBuffersList.push("Light" + lightIndex);
 
                 samplersList.push("shadowSampler" + lightIndex);
             }

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

@@ -1112,10 +1112,12 @@
                 
                 ColorCurves.PrepareUniforms(uniforms); 
                 ColorGradingTexture.PrepareUniformsAndSamplers(uniforms, samplers); 
-                MaterialHelper.PrepareUniformsAndSamplersList(uniforms, samplers, this._defines, this.maxSimultaneousLights); 
+                MaterialHelper.PrepareUniformsAndSamplersList(uniforms, [], samplers, this._defines, this.maxSimultaneousLights); 
                 
                 this._effect = scene.getEngine().createEffect("pbr",
-                    attribs, uniforms, samplers,
+                    attribs, uniforms, 
+                    [],
+                    samplers,
                     join, fallbacks, this.onCompiled, this.onError, {maxSimultaneousLights: this.maxSimultaneousLights, maxSimultaneousMorphTargets: this._defines.NUM_MORPH_INFLUENCERS});
             }
             if (!this._effect.isReady()) {

+ 2 - 0
src/Materials/babylon.shaderMaterial.ts

@@ -26,6 +26,7 @@
             options.needAlphaTesting = options.needAlphaTesting || false;
             options.attributes = options.attributes || ["position", "normal", "uv"];
             options.uniforms = options.uniforms || ["worldViewProjection"];
+            options.uniformBuffers = options.uniformBuffers || [];
             options.samplers = options.samplers || [];
             options.defines = options.defines || [];
 
@@ -208,6 +209,7 @@
             this._effect = engine.createEffect(this._shaderPath,
                 this._options.attributes,
                 this._options.uniforms,
+                this._options.uniformBuffers,
                 this._options.samplers,
                 join, fallbacks, this.onCompiled, this.onError);
 

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

@@ -699,17 +699,16 @@ module BABYLON {
                 }
 
                 var join = defines.toString();
-                var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
-                    "vFogInfos", "vFogColor", "pointSize",
-                    "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
+                var uniforms = ["world", "view", "vEyePosition", "vLightsType",
+                    "vFogInfos", "vFogColor",
                     "mBones",
-                    "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
+                    "vClipPlane",
                     "depthValues",
-                    "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
                     "logarithmicDepthConstant"
                 ];
 
                 var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler"]
+                var uniformBuffers = ["Material", "Scene"];
 
                 if (defines.CAMERACOLORCURVES) {
                     ColorCurves.PrepareUniforms(uniforms);
@@ -717,7 +716,7 @@ module BABYLON {
                 if (defines.CAMERACOLORGRADING) {
                     ColorGradingTexture.PrepareUniformsAndSamplers(uniforms, samplers);
                 }
-                MaterialHelper.PrepareUniformsAndSamplersList(uniforms, samplers, defines, this._maxSimultaneousLights);
+                MaterialHelper.PrepareUniformsAndSamplersList(uniforms, uniformBuffers, samplers, defines, this._maxSimultaneousLights);
 
                 var onCompiled = function(effect) {
                     if (this.onCompiled) {
@@ -728,7 +727,7 @@ module BABYLON {
                 }.bind(this);
 
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName,
-                    attribs, uniforms, samplers,
+                    attribs, uniforms, uniformBuffers, samplers,
                     join, fallbacks, onCompiled, this.onError, { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }), defines);
 
                 this.buildUniformLayout();
@@ -782,6 +781,7 @@ module BABYLON {
             this._uniformBuffer.addUniform("vDiffuseColor", 4);
             this._uniformBuffer.addUniform("pointSize", 1);
         }
+        
         public unbind(): void {
             if (this._activeEffect) {
                 if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {

+ 1 - 0
src/Particles/babylon.particleSystem.ts

@@ -298,6 +298,7 @@
                     "particles",
                     [VertexBuffer.PositionKind, VertexBuffer.ColorKind, "options"],
                     ["invView", "view", "projection", "vClipPlane", "textureMask"],
+                    [],
                     ["diffuseSampler"], join);
             }
 

+ 1 - 0
src/PostProcess/babylon.postProcess.ts

@@ -133,6 +133,7 @@
             this._effect = this._engine.createEffect({ vertex: "postprocess", fragment: this._fragmentUrl },
                 ["position"],
                 this._parameters,
+                [],
                 this._samplers, defines !== undefined ? defines : "");
         }
 

+ 1 - 0
src/PostProcess/babylon.volumetricLightScatteringPostProcess.ts

@@ -188,6 +188,7 @@
                     { vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" },
                     attribs,
                     ["world", "mBones", "viewProjection", "diffuseMatrix"],
+                    [],
                     ["diffuseSampler"], join);
             }
 

+ 1 - 0
src/Rendering/babylon.depthRenderer.ts

@@ -142,6 +142,7 @@
                 this._effect = this._scene.getEngine().createEffect("depth",
                     attribs,
                     ["world", "mBones", "viewProjection", "diffuseMatrix", "far"],
+                    [],
                     ["diffuseSampler"], join);
             }
 

+ 1 - 0
src/Rendering/babylon.outlineRenderer.ts

@@ -94,6 +94,7 @@
                 this._effect = this._scene.getEngine().createEffect("outline",
                     attribs,
                     ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color"],
+                    [],
                     ["diffuseSampler"], join);
             }
 

+ 33 - 34
src/Shaders/default.fragment.fx

@@ -2,7 +2,6 @@
 
 uniform Material
 {
-	
 	vec4 diffuseLeftColor;
 	vec4 diffuseRightColor;
 	vec4 opacityParts;
@@ -34,7 +33,7 @@ uniform Material
 	vec3 vEmissiveColor;
 	vec4 vDiffuseColor;
 	float pointSize;
-} uMaterial;
+};
 
 uniform vec3 vEyePosition;
 uniform vec3 vAmbientColor;
@@ -161,10 +160,10 @@ void main(void) {
 
 	// Base color
 	vec4 baseColor = vec4(1., 1., 1., 1.);
-	vec3 diffuseColor = uMaterial.vDiffuseColor.rgb;
+	vec3 diffuseColor = vDiffuseColor.rgb;
 
 	// Alpha
-	float alpha = uMaterial.vDiffuseColor.a;
+	float alpha = vDiffuseColor.a;
 
 	// Bump
 #ifdef NORMAL
@@ -191,7 +190,7 @@ void main(void) {
 	alpha *= baseColor.a;
 #endif
 
-	baseColor.rgb *= uMaterial.vDiffuseInfos.y;
+	baseColor.rgb *= vDiffuseInfos.y;
 #endif
 
 #ifdef VERTEXCOLOR
@@ -202,13 +201,13 @@ void main(void) {
 	vec3 baseAmbientColor = vec3(1., 1., 1.);
 
 #ifdef AMBIENT
-	baseAmbientColor = texture2D(ambientSampler, vAmbientUV + uvOffset).rgb * uMaterial.vAmbientInfos.y;
+	baseAmbientColor = texture2D(ambientSampler, vAmbientUV + uvOffset).rgb * vAmbientInfos.y;
 #endif
 
 	// Specular map
 #ifdef SPECULARTERM
-	float glossiness = uMaterial.vSpecularColor.a;
-	vec3 specularColor = uMaterial.vSpecularColor.rgb;
+	float glossiness = vSpecularColor.a;
+	vec3 specularColor = vSpecularColor.rgb;
 
 #ifdef SPECULAR
 	vec4 specularMapColor = texture2D(specularSampler, vSpecularUV + uvOffset);
@@ -230,7 +229,7 @@ void main(void) {
 	float shadow = 1.;
 
 #ifdef LIGHTMAP
-	vec3 lightmapColor = texture2D(lightmapSampler, vLightmapUV + uvOffset).rgb * uMaterial.vLightmapInfos.y;
+	vec3 lightmapColor = texture2D(lightmapSampler, vLightmapUV + uvOffset).rgb * vLightmapInfos.y;
 #endif
 
 #include<lightFragment>[0..maxSimultaneousLights]
@@ -239,23 +238,23 @@ void main(void) {
 	vec3 refractionColor = vec3(0., 0., 0.);
 
 #ifdef REFRACTION
-	vec3 refractionVector = normalize(refract(-viewDirectionW, normalW, uMaterial.vRefractionInfos.y));
+	vec3 refractionVector = normalize(refract(-viewDirectionW, normalW, vRefractionInfos.y));
 #ifdef REFRACTIONMAP_3D
 
-	refractionVector.y = refractionVector.y * uMaterial.vRefractionInfos.w;
+	refractionVector.y = refractionVector.y * vRefractionInfos.w;
 
 	if (dot(refractionVector, viewDirectionW) < 1.0)
 	{
-		refractionColor = textureCube(refractionCubeSampler, refractionVector).rgb * uMaterial.vRefractionInfos.x;
+		refractionColor = textureCube(refractionCubeSampler, refractionVector).rgb * vRefractionInfos.x;
 	}
 #else
-	vec3 vRefractionUVW = vec3(uMaterial.refractionMatrix * (view * vec4(vPositionW + refractionVector * uMaterial.vRefractionInfos.z, 1.0)));
+	vec3 vRefractionUVW = vec3(refractionMatrix * (view * vec4(vPositionW + refractionVector * vRefractionInfos.z, 1.0)));
 
 	vec2 refractionCoords = vRefractionUVW.xy / vRefractionUVW.z;
 
 	refractionCoords.y = 1.0 - refractionCoords.y;
 
-	refractionColor = texture2D(refraction2DSampler, refractionCoords).rgb * uMaterial.vRefractionInfos.x;
+	refractionColor = texture2D(refraction2DSampler, refractionCoords).rgb * vRefractionInfos.x;
 #endif
 #endif
 
@@ -267,7 +266,7 @@ void main(void) {
 
 #ifdef REFLECTIONMAP_3D
 #ifdef ROUGHNESS
-	float bias = uMaterial.vReflectionInfos.y;
+	float bias = vReflectionInfos.y;
 
 #ifdef SPECULARTERM
 	#ifdef SPECULAR
@@ -277,9 +276,9 @@ void main(void) {
 	#endif
 #endif
 
-	reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW, bias).rgb * uMaterial.vReflectionInfos.x;
+	reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW, bias).rgb * vReflectionInfos.x;
 #else
-	reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW).rgb * uMaterial.vReflectionInfos.x;
+	reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW).rgb * vReflectionInfos.x;
 #endif
 
 #else
@@ -291,28 +290,28 @@ void main(void) {
 
 	coords.y = 1.0 - coords.y;
 
-	reflectionColor = texture2D(reflection2DSampler, coords).rgb * uMaterial.vReflectionInfos.x;
+	reflectionColor = texture2D(reflection2DSampler, coords).rgb * vReflectionInfos.x;
 #endif
 
 #ifdef REFLECTIONFRESNEL
-	float reflectionFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, uMaterial.reflectionRightColor.a, uMaterial.reflectionLeftColor.a);
+	float reflectionFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, reflectionRightColor.a, reflectionLeftColor.a);
 
 #ifdef REFLECTIONFRESNELFROMSPECULAR
 #ifdef SPECULARTERM
-	reflectionColor *= specularColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * uMaterial.reflectionRightColor.rgb;
+	reflectionColor *= specularColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * reflectionRightColor.rgb;
 #else
-	reflectionColor *= uMaterial.reflectionLeftColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * uMaterial.reflectionRightColor.rgb;
+	reflectionColor *= reflectionLeftColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * reflectionRightColor.rgb;
 #endif
 #else
-	reflectionColor *= uMaterial.reflectionLeftColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * uMaterial.reflectionRightColor.rgb;
+	reflectionColor *= reflectionLeftColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * reflectionRightColor.rgb;
 #endif
 #endif
 #endif
 
 #ifdef REFRACTIONFRESNEL
-	float refractionFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, uMaterial.refractionRightColor.a, uMaterial.refractionLeftColor.a);
+	float refractionFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, refractionRightColor.a, refractionLeftColor.a);
 
-	refractionColor *= uMaterial.refractionLeftColor.rgb * (1.0 - refractionFresnelTerm) + refractionFresnelTerm * uMaterial.refractionRightColor.rgb;
+	refractionColor *= refractionLeftColor.rgb * (1.0 - refractionFresnelTerm) + refractionFresnelTerm * refractionRightColor.rgb;
 #endif
 
 #ifdef OPACITY
@@ -320,9 +319,9 @@ void main(void) {
 
 #ifdef OPACITYRGB
 	opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11);
-	alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* uMaterial.vOpacityInfos.y;
+	alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y;
 #else
-	alpha *= opacityMap.a * uMaterial.vOpacityInfos.y;
+	alpha *= opacityMap.a * vOpacityInfos.y;
 #endif
 
 #endif
@@ -332,28 +331,28 @@ void main(void) {
 #endif
 
 #ifdef OPACITYFRESNEL
-	float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, uMaterial.opacityParts.z, uMaterial.opacityParts.w);
+	float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w);
 
-	alpha += uMaterial.opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * uMaterial.opacityParts.y;
+	alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y;
 #endif
 
 	// Emissive
-	vec3 emissiveColor = uMaterial.vEmissiveColor;
+	vec3 emissiveColor = vEmissiveColor;
 #ifdef EMISSIVE
-	emissiveColor += texture2D(emissiveSampler, vEmissiveUV + uvOffset).rgb * uMaterial.vEmissiveInfos.y;
+	emissiveColor += texture2D(emissiveSampler, vEmissiveUV + uvOffset).rgb * vEmissiveInfos.y;
 #endif
 
 #ifdef EMISSIVEFRESNEL
-	float emissiveFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, uMaterial.emissiveRightColor.a, uMaterial.emissiveLeftColor.a);
+	float emissiveFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, emissiveRightColor.a, emissiveLeftColor.a);
 
-	emissiveColor *= uMaterial.emissiveLeftColor.rgb * (1.0 - emissiveFresnelTerm) + emissiveFresnelTerm * uMaterial.emissiveRightColor.rgb;
+	emissiveColor *= emissiveLeftColor.rgb * (1.0 - emissiveFresnelTerm) + emissiveFresnelTerm * emissiveRightColor.rgb;
 #endif
 
 	// Fresnel
 #ifdef DIFFUSEFRESNEL
-	float diffuseFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, uMaterial.diffuseRightColor.a, uMaterial.diffuseLeftColor.a);
+	float diffuseFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, diffuseRightColor.a, diffuseLeftColor.a);
 
-	diffuseBase *= uMaterial.diffuseLeftColor.rgb * (1.0 - diffuseFresnelTerm) + diffuseFresnelTerm * uMaterial.diffuseRightColor.rgb;
+	diffuseBase *= diffuseLeftColor.rgb * (1.0 - diffuseFresnelTerm) + diffuseFresnelTerm * diffuseRightColor.rgb;
 #endif
 
 	// Composition

+ 24 - 25
src/Shaders/default.vertex.fx

@@ -2,7 +2,6 @@
 
 uniform Material
 {
-	
 	vec4 diffuseLeftColor;
 	vec4 diffuseRightColor;
 	vec4 opacityParts;
@@ -34,11 +33,11 @@ uniform Material
 	vec3 vEmissiveColor;
 	vec4 vDiffuseColor;
 	float pointSize;
-} uMaterial;
+};
 
 uniform Scene {
 	mat4 viewProjection;
-} uScene;
+};
 
 // Attributes
 attribute vec3 position;
@@ -140,7 +139,7 @@ void main(void) {
 #include<instancesVertex>
 #include<bonesVertex>
 
-	gl_Position = uScene.viewProjection * finalWorld * vec4(positionUpdated, 1.0);
+	gl_Position = viewProjection * finalWorld * vec4(positionUpdated, 1.0);
 
 	vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
 	vPositionW = vec3(worldPos);
@@ -162,79 +161,79 @@ void main(void) {
 #endif
 
 #ifdef DIFFUSE
-	if (uMaterial.vDiffuseInfos.x == 0.)
+	if (vDiffuseInfos.x == 0.)
 	{
-		vDiffuseUV = vec2(uMaterial.diffuseMatrix * vec4(uv, 1.0, 0.0));
+		vDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
 	}
 	else
 	{
-		vDiffuseUV = vec2(uMaterial.diffuseMatrix * vec4(uv2, 1.0, 0.0));
+		vDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
 	}
 #endif
 
 #ifdef AMBIENT
-	if (uMaterial.vAmbientInfos.x == 0.)
+	if (vAmbientInfos.x == 0.)
 	{
-		vAmbientUV = vec2(uMaterial.ambientMatrix * vec4(uv, 1.0, 0.0));
+		vAmbientUV = vec2(ambientMatrix * vec4(uv, 1.0, 0.0));
 	}
 	else
 	{
-		vAmbientUV = vec2(uMaterial.ambientMatrix * vec4(uv2, 1.0, 0.0));
+		vAmbientUV = vec2(ambientMatrix * vec4(uv2, 1.0, 0.0));
 	}
 #endif
 
 #ifdef OPACITY
-	if (uMaterial.vOpacityInfos.x == 0.)
+	if (vOpacityInfos.x == 0.)
 	{
-		vOpacityUV = vec2(uMaterial.opacityMatrix * vec4(uv, 1.0, 0.0));
+		vOpacityUV = vec2(opacityMatrix * vec4(uv, 1.0, 0.0));
 	}
 	else
 	{
-		vOpacityUV = vec2(uMaterial.opacityMatrix * vec4(uv2, 1.0, 0.0));
+		vOpacityUV = vec2(opacityMatrix * vec4(uv2, 1.0, 0.0));
 	}
 #endif
 
 #ifdef EMISSIVE
-	if (uMaterial.vEmissiveInfos.x == 0.)
+	if (vEmissiveInfos.x == 0.)
 	{
-		vEmissiveUV = vec2(uMaterial.emissiveMatrix * vec4(uv, 1.0, 0.0));
+		vEmissiveUV = vec2(emissiveMatrix * vec4(uv, 1.0, 0.0));
 	}
 	else
 	{
-		vEmissiveUV = vec2(uMaterial.emissiveMatrix * vec4(uv2, 1.0, 0.0));
+		vEmissiveUV = vec2(emissiveMatrix * vec4(uv2, 1.0, 0.0));
 	}
 #endif
 
 #ifdef LIGHTMAP
-	if (uMaterial.vLightmapInfos.x == 0.)
+	if (vLightmapInfos.x == 0.)
 	{
-		vLightmapUV = vec2(uMaterial.lightmapMatrix * vec4(uv, 1.0, 0.0));
+		vLightmapUV = vec2(lightmapMatrix * vec4(uv, 1.0, 0.0));
 	}
 	else
 	{
-		vLightmapUV = vec2(uMaterial.lightmapMatrix * vec4(uv2, 1.0, 0.0));
+		vLightmapUV = vec2(lightmapMatrix * vec4(uv2, 1.0, 0.0));
 	}
 #endif
 
 #if defined(SPECULAR) && defined(SPECULARTERM)
-	if (uMaterial.vSpecularInfos.x == 0.)
+	if (vSpecularInfos.x == 0.)
 	{
-		vSpecularUV = vec2(uMaterial.specularMatrix * vec4(uv, 1.0, 0.0));
+		vSpecularUV = vec2(specularMatrix * vec4(uv, 1.0, 0.0));
 	}
 	else
 	{
-		vSpecularUV = vec2(uMaterial.specularMatrix * vec4(uv2, 1.0, 0.0));
+		vSpecularUV = vec2(specularMatrix * vec4(uv2, 1.0, 0.0));
 	}
 #endif
 
 #ifdef BUMP
-	if (uMaterial.vBumpInfos.x == 0.)
+	if (vBumpInfos.x == 0.)
 	{
-		vBumpUV = vec2(uMaterial.bumpMatrix * vec4(uv, 1.0, 0.0));
+		vBumpUV = vec2(bumpMatrix * vec4(uv, 1.0, 0.0));
 	}
 	else
 	{
-		vBumpUV = vec2(uMaterial.bumpMatrix * vec4(uv2, 1.0, 0.0));
+		vBumpUV = vec2(bumpMatrix * vec4(uv2, 1.0, 0.0));
 	}
 #endif
 

+ 2 - 0
src/Sprites/babylon.spriteManager.ts

@@ -96,11 +96,13 @@
             this._effectBase = this._scene.getEngine().createEffect("sprites",
                 [VertexBuffer.PositionKind, "options", "cellInfo", VertexBuffer.ColorKind],
                 ["view", "projection", "textureInfos", "alphaTest"],
+                [],
                 ["diffuseSampler"], "");
 
             this._effectFog = this._scene.getEngine().createEffect("sprites",
                 [VertexBuffer.PositionKind, "options", "cellInfo", VertexBuffer.ColorKind],
                 ["view", "projection", "textureInfos", "alphaTest", "vFogInfos", "vFogColor"],
+                [],
                 ["diffuseSampler"], "#define FOG");
         }
 

+ 3 - 2
src/babylon.engine.ts

@@ -1802,7 +1802,7 @@
             }
         }
 
-        public createEffect(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks,
+        public createEffect(baseName: any, attributesNames: string[], uniformsNames: string[], uniformBuffers: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks,
             onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect {
             var vertex = baseName.vertexElement || baseName.vertex || baseName;
             var fragment = baseName.fragmentElement || baseName.fragment || baseName;
@@ -1812,7 +1812,7 @@
                 return this._compiledEffects[name];
             }
 
-            var effect = new Effect(baseName, attributesNames, uniformsNames, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
+            var effect = new Effect(baseName, attributesNames, uniformsNames, uniformBuffers, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
             effect._key = name;
             this._compiledEffects[name] = effect;
 
@@ -1829,6 +1829,7 @@
                 },
                 ["position", "color", "options"],
                 ["view", "projection"].concat(uniformsNames),
+                [],
                 ["diffuseSampler"].concat(samplers), defines, fallbacks, onCompiled, onError);
         }