Error retrieving loc3 for 3
uniform vec4 loc0, loc1, loc2, loc3, loc4;
uniform sampler3D tex0;
uniform sampler3D tex1;
uniform sampler2D tex2;
uniform samplerRECT tex3;
void main()
{
vec4 t = gl_TexCoord[0];
vec4 v;
vec4 c;
vec4 l = loc0; // {lx, ly, lz, alpha}
vec4 k = loc1; // {ka, kd, ks, ns}
vec4 g = loc2; // {1/gradrange, -gradmin/gradrange, 0, 0}
vec4 n, w;
v = texture3D(tex0, t.stp);
n = (v * 2.0) - 1.0; // rescale from [0,1] to [-1,1]
n.w = dot(n.xyz, n.xyz);
n.w = inversesqrt(n.w);
n = n * n.w; // n = n / length(normal)
n.w = dot(l.xyz, n.xyz); // calculate angle between light and normal
n.w = clamp(abs(n.w), 0.0, 1.0); // two-sided lighting, n.w = abs(cos(angle))
w = k; // w.x = weight*ka, w.y = weight*kd, w.z = weight*ks
w.x = k.x - w.y; // w.x = ka - kd * weight
w.x = w.x + k.y; // w.x = ka + kd - kd*weight
n.z = power(n.w, k.w); // n.z = abs(cos(angle))^ns
n.w = (n.w * w.y) + w.x; // n.w = abs(cos(angle))*kd+ka
n.z = w.z * n.z; // n.z = weight*ks*abs(cos(angle))^ns
v.x = texture3D(tex1, t.stp);
c = texture2D(tex2, v.wx);
n.z = n.z * c.w;
c.xyz = (c.xyzz * n.w) + n.z;
gl_FragColor = c;
}