update: The problem seems to be the G and B values. When I change them, nothing happens. Its weird because by default the values are 1.0,1.0,1.0,1.0 for specular lighting.

Hi guys,

first off, thanks for your help. I have been having difficulty with my glsl shader. I am suppose to implement the phoung model in the vertex shader. It seems to work for the most part, except my specular value is wrong I believe. When I run the program, my model appears red instead of white. I have two windows running. One is the opengl implementation which shows the correct output. I am trying to get my shader to match its output. Here is my code. I have gone through the red book, and can't find anything wrong in my calculation

//calculate specular term

//for the specular term, we need to get the halfway vector between the viewer and light.

//If L · n is less than or equal to zero, there is no specular component at the vertex

if(dot(L,normal) <= 0.0)

specularTerm = specularTerm * vec4(0.0,0.0,0.0,0.0);

else{

//calculate the halfway vector and normalize it

halfwayVector =normalize(gl_LightSource[0].halfVector.xyz);

//this gives us the "s" value from opengl pg 244

//so now calculate the specular term

//(max {s · n, 0})^shininess * specularlight * specularmaterial

float maxV = max(dot(halfwayVector,normal),0.0);

//we dont want 0^0 possibility in opengl

if(maxV > 0.0)

specularTerm = pow(maxV,shine) * gl_LightSource[0].specular * specularMaterial;

else//since 0 raised to anything is 1

specularTerm = gl_LightSource[0].specular * specularMaterial;

}

Another problem I am having is with the shading type. My shader doesn't seem to recognize when glEnable(Flat) and glEnable(smooth) are on, yet it recognizes when lights are on/off.

Here is a picture

Thanks for your help!