My method of calculating the specular of an object has failed. I think the title is self-explanatory enough, but i put together a short, 15-second YouTube video to show you just in case.
Vert:
varying vec3 vertex_light_position;
varying vec3 vertex_light_half_vector;
varying vec3 vertex_normal;
varying vec4 color;
varying vec3 N;
varying vec3 v;
void main(void)
{
v = vec3(gl_ModelViewMatrix * gl_Vertex);
N = normalize(gl_NormalMatrix * gl_Normal);
color = vec4(0.0,0.0,1.0,1.0);
vertex_normal = normalize(gl_NormalMatrix * gl_Normal);
vertex_light_position = normalize(gl_LightSource[0].position.xyz);
vertex_light_half_vector = normalize(gl_LightSource[0].halfVector.xyz);
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
Frag:
varying vec3 vertex_light_position;
varying vec3 vertex_light_half_vector;
varying vec3 vertex_normal;
varying vec4 color;
varying vec3 N;
varying vec3 v;
void main()
{
float cosAngIncidence = dot(vertex_normal, vec3(0.0));
cosAngIncidence = clamp(cosAngIncidence, 0, 1);
vec4 spec;
vec3 L = normalize(gl_LightSource[0].position.xyz - v);
vec3 E = normalize(-v);
vec3 R = normalize(reflect(-L,N));
if(cosAngIncidence == 0.0){
spec = clamp (gl_FrontMaterial.specular * pow(max(dot(R,E),0.0),0.3*gl_FrontMaterial.shininess) , 0.0, 1.0 );
}else{
spec = vec4(0,0,0,0);
}
gl_FragColor = (other colors etc....) + spec;
}
*note only included the code regarding specular lighting.
I appreciate all answers!