Hi there, just wanted to ask for some help, because this glsl code turns out to be so slow, is there any other (faster) way to do the same thing, basically it looses 200fps per texture added
[VERTEX]
uniform mat4 uModelViewProjectionMatrix, uNormalMatrix, uModelMatrix, uViewMatrix;
attribute vec2 aPosition, aTexcoord;
attribute vec3 aNormal;
attribute float aHeight;
attribute float aPaintLayer1, aPaintLayer2, aPaintLayer3, aPaintLayer4, aPaintLayer5, aPaintLayer6, aPaintLayer7, aPaintLayer8;
varying vec3 vNormal;
varying vec2 vTexcoord0;
varying float vPaintLayer1, vPaintLayer2, vPaintLayer3, vPaintLayer4, vPaintLayer5, vPaintLayer6, vPaintLayer7, vPaintLayer8;
void main() {
gl_Position = uModelViewProjectionMatrix * vec4(aPosition.x,aHeight,aPosition.y,1);
vNormal = (uNormalMatrix * vec4(aNormal,0)).xyz;
vTexcoord0 = aTexcoord;
vPaintLayer1 = aPaintLayer1;
vPaintLayer2 = aPaintLayer2;
vPaintLayer3 = aPaintLayer3;
vPaintLayer4 = aPaintLayer4;
vPaintLayer5 = aPaintLayer5;
vPaintLayer6 = aPaintLayer6;
vPaintLayer7 = aPaintLayer7;
vPaintLayer8 = aPaintLayer8;
};
[FRAGMENT]
uniform sampler2D uLayerTex0, uLayerTex1, uLayerTex2, uLayerTex3, uLayerTex4, uLayerTex5, uLayerTex6, uLayerTex7;
varying vec3 vNormal;
varying vec2 vTexcoord0;
varying float vPaintLayer1, vPaintLayer2, vPaintLayer3, vPaintLayer4, vPaintLayer5, vPaintLayer6, vPaintLayer7, vPaintLayer8;
void main() {
vec4 color1 = texture2D(uLayerTex0,vTexcoord0.st)*vPaintLayer1;
vec4 color2 = texture2D(uLayerTex1,vTexcoord0.st)*vPaintLayer2;
vec4 color3 = texture2D(uLayerTex2,vTexcoord0.st)*vPaintLayer3;
vec4 color4 = texture2D(uLayerTex3,vTexcoord0.st)*vPaintLayer4;
vec4 color5 = texture2D(uLayerTex4,vTexcoord0.st)*vPaintLayer5;
vec4 color6 = texture2D(uLayerTex5,vTexcoord0.st)*vPaintLayer6;
vec4 color7 = texture2D(uLayerTex6,vTexcoord0.st)*vPaintLayer7;
vec4 color8 = texture2D(uLayerTex7,vTexcoord0.st)*vPaintLayer8;
float nDotL = max(0.0, dot(normalize(vNormal), vec3(0.5,0.5,0)));
vec4 ambient = vec4(0.1,0.1,0.1,0.1);
vec4 diffuse = vec4(1,1,1,1) * nDotL;
gl_FragColor = vec4(color1 + color2 + color3 + color4 + color5 + color6 + color7 + color8) * (ambient + diffuse);
};
Thanks in advance