Android OpenGL es 2.0 specular light

I’m trying to add specular lightning to my android OpenGL project, but the light is only projected on a part of my object, as you can see in my example:
(cant insert image… :()

In my fragment shader, I calculate the color as following:

float dot(vec3 v1, vec3 v2)
{
    return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
}

void main()
{
    float distSqr = dot(lightDir, lightDir);
    float att = clamp(1.0 - 0.001 * sqrt(distSqr), 0.0, 1.0);
    vec3 L = lightDir * inversesqrt(distSqr);

    vec4 baseColor = texture2D(texture1, tCoord);

    vec3 N = normalize(baseColor.xyz * 2.0 - 1.0);

    vec3 E = normalize(eyeVec);

    vec3 reflectV = reflect(-L, N);

    vec4 ambientTerm = baseColor;

    // base * diffuse * max(dot(N, L), 0.0)
    vec4 diffuseTerm = baseColor * matDiffuse * max(dot(N, L), 0.0);
    //vec4 diffuseTerm = baseColor * gl_FrontMaterial.diffuse * max(dot(N, L), 0.0);

    // spec * pow(max(dot(reflectV, E), 0.0), shininess)
    vec4 specularTerm = matSpecular * pow(max(dot(reflectV, E), 0.0), 5.0);
    //vec4 specularTerm = vec4(1.0, 1.0, 1.0, 1.0) * pow(max(dot(reflectV, E), 0.0), 5.0);

    gl_FragColor = (ambientTerm + diffuseTerm + specularTerm) * att;
}

The light position is: 0, 2, 2

If you need more info, please ask for it.

Post is also posted on stack overflow, with the same title (and image)

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.