strange problem of glsl

Started by
-1 comments, last by trai 17 years ago
I wrote a ground shader using glsl, but the result is diffent from the original fixed opengl pipeline!!! In my vertex shader, I wrote(simplified): lightDir = normalize(gl_LightSource[0].position.xyz); halfVector = normalize(gl_LightSource[0].halfVector.xyz); NdotL = max(dot(normal,lightDir),0.0); if(NdotL>0.0) { NdotHV = max(dot(normal,halfVector),0.0); color = gl_FrontMaterial.specular * gl_LightSource[0].specular* pow(NdotHV, gl_FrontMaterial.shininess); } I have only consider the specular term of light, and I found that the resulting image is not the same as the image from fiexd opengl pipeline. Of course, I have do some test and try to fiture out. But I cant confirm my thought. When use this to alternate the halfVector: halfVector = normalize(-vertexCood.xyz+lightDir.xyz); the result is different from using builded in halfVector. It's strange that why the two halfVector are different?? I thought the builed in halfVector uses the fixed "viewing vector" for all verteies until the viewing position or object is moving. And the halfVector calcuated myself is that the viewing vector is different for every vertexies. Is this true? Thank you for reading and answering my question.:D

This topic is closed to new replies.

Advertisement