The problem is in my Fragment Shader.
varying vec4 diffuse[4];
varying vec4 ambient[4];
varying vec3 normal;
varying vec3 lightDir[4];
varying vec3 halfVector[4];
varying float dist[4];
void main(void)
{
vec3 n, halfV;
float NdotL,NdotHV;
vec4 fragmentColor[6];
vec4 finalColor;
float att;
n = normalize(normal);
for(int i = 0; i < 4; i++)
{
NdotL = max(dot(n,lightDir), 0.0);
if (NdotL > 0.0)
{
att = 1.0 / (gl_LightSource.constantAttenuation
+ gl_LightSource.linearAttenuation * dist
+ gl_LightSource.quadraticAttenuation * dist * dist);
fragmentColor = att * diffuse * NdotL + ambient;
halfV = normalize(halfVector);
NdotHV = max(dot(n,halfV),0.0);
fragmentColor += att * gl_FrontMaterial.specular * gl_LightSource.specular * pow(NdotHV, gl_FrontMaterial.shininess);
}
}
// This is the latest attempt to get it to work
finalColor = vec4(fragmentColor[0].xyz + fragmentColor[1].xyz + fragmentColor[2].xyz, 1); //Works Fine without the next line
finalColor += vec4(fragmentColor[3].xyz, 1); // This is where the problem is
//finalColor = vec4(fragmentColor[3].xyz, 1); <- Works fine
//finalColor = vec4(6,1,1,1); <- Works Fine
gl_FragColor = finalColor;
}
Everytime I want to add a fourth vec4 to gl_FragColor or assign the a vec4 that is the sum of 4 differente vec4s the Shader just wont work.
If its three vec4s there is no problem