pixel shader

// constant values sent through from AGK code.
uniform sampler2D texture0;
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D texture3;
uniform sampler2D texture4;
uniform sampler2D texture5;
uniform sampler2D texture6;
uniform sampler2D texture7;
uniform vec4 fade;
uniform vec4 fade2;
uniform highp vec4 agk_bonequats1[100];
uniform highp vec4 agk_bonequats2[100];
// Anything that the vertex shader passes as output needs to
// be defined here as input. The vertex shader is passing the
// texture coordinate, so it is defined again here.
varying vec2 uv0Varying;
varying vec2 uv1Varying;
varying vec2 uv2Varying;
varying vec2 uv3Varying;
varying vec2 uv4Varying;
varying vec2 uv5Varying;
varying vec2 uv6Varying;
varying vec2 uv7Varying;
void main()
{
// copy the textures coords
vec2 texCoord0 = uv0Varying;
vec2 texCoord1 = uv1Varying;
vec2 texCoord2 = uv2Varying;
vec2 texCoord3 = uv3Varying;
vec2 texCoord4 = uv4Varying;
vec2 texCoord5 = uv5Varying;
vec2 texCoord6 = uv6Varying;
vec2 texCoord7 = uv7Varying;
vec4 colorResult0 = texture2D(texture0, texCoord0);
vec4 colorResult1 = texture2D(texture1, texCoord0);
vec4 colorResult2 = texture2D(texture2, texCoord0);
vec4 colorResult3 = texture2D(texture3, texCoord0);
vec4 colorResult4 = texture2D(texture4, texCoord0);
vec4 colorResult5 = texture2D(texture5, texCoord0);
vec4 colorResult6 = texture2D(texture6, texCoord0);
vec4 colorResult7 = texture2D(texture7, texCoord0);
colorResult1.a *= fade.x;
colorResult2.a *= fade.y;
colorResult3.a *= fade.z;
colorResult4.a *= fade.w;
colorResult5.a *= fade2.x;
colorResult6.a *= fade2.y;
colorResult7.a *= fade2.z;
gl_FragColor = mix(colorResult0, colorResult1, colorResult1.a);
gl_FragColor = mix(gl_FragColor, colorResult2, colorResult2.a);
gl_FragColor = mix(gl_FragColor, colorResult3, colorResult3.a);
gl_FragColor = mix(gl_FragColor, colorResult4, colorResult4.a);
gl_FragColor = mix(gl_FragColor, colorResult5, colorResult5.a);
gl_FragColor = mix(gl_FragColor, colorResult6, colorResult6.a);
gl_FragColor = mix(gl_FragColor, colorResult7, colorResult7.a);
}

vertex shader

attribute highp vec3 position;
attribute mediump vec3 normal;
varying vec2 uv0Varying;
varying vec2 uv1Varying;
varying vec2 uv2Varying;
varying vec2 uv3Varying;
varying vec2 uv4Varying;
varying vec2 uv5Varying;
varying vec2 uv6Varying;
varying vec2 uv7Varying;
varying highp vec3 posVarying;
varying mediump vec3 normalVarying;
varying mediump vec3 lightVarying;
mediump vec3 GetVSLighting( mediump vec3 normal, highp vec3 pos );
uniform highp mat4 agk_ViewProj;
attribute highp vec2 uv;
varying highp vec2 uvVarying;
uniform highp vec4 uvBounds0;
attribute highp vec4 boneweights;
attribute mediump vec4 boneindices;
uniform highp vec4 agk_bonequats1[28];
uniform highp vec4 agk_bonequats2[28];
highp vec3 transformDQ( highp vec3 p, highp vec4 q1, highp vec4 q2 )
{
p += 2.0 * cross( q1.xyz, cross(q1.xyz, p) + q1.w*p );
p += 2.0 * (q1.w*q2.xyz - q2.w*q1.xyz + cross(q1.xyz,q2.xyz));
return p;
}
void main()
{
uv0Varying = uv * uvBounds0.xy + uvBounds0.zw;
uvVarying = uv * uvBounds0.xy + uvBounds0.zw;
highp vec4 q1 = agk_bonequats1[ int(boneindices.x) ] * boneweights.x;
q1 += agk_bonequats1[ int(boneindices.y) ] * boneweights.y;
q1 += agk_bonequats1[ int(boneindices.z) ] * boneweights.z;
q1 += agk_bonequats1[ int(boneindices.w) ] * boneweights.w;
highp vec4 q2 = agk_bonequats2[ int(boneindices.x) ] * boneweights.x;
q2 += agk_bonequats2[ int(boneindices.y) ] * boneweights.y;
q2 += agk_bonequats2[ int(boneindices.z) ] * boneweights.z;
q2 += agk_bonequats2[ int(boneindices.w) ] * boneweights.w;
highp float len = 1.0/length(q1);
q1 *= len;
q2 = (q2 - q1*dot(q1,q2)) * len;
highp vec4 pos = vec4( transformDQ(position,q1,q2), 1.0 );
gl_Position = agk_ViewProj * pos;
normalVarying = normal + 2.0*cross( q1.xyz, cross(q1.xyz,normal) + q1.w*normal );
posVarying = pos.xyz;
lightVarying = GetVSLighting( normalVarying, posVarying );
}