/* first transform the normal into eye space and normalize the result */
normal = normalize(gl_NormalMatrix * gl_Normal);
Normals, GLSL, FP/VP
I have per pixel lighting setup and running in a FP/VP using a DOT3 Bumpmap. So now I am moving to GLSL and my lighting is all messed up... I am not using the DOT3 bumpmap, I am as of now unsure what is wrong.
#1. With GLSL do I still need to process my normals as I did before on the CPU? I am using a VBO to store my whole terrain data in. e.g. vertex, normals, texcoords. Or can the normals be done in GLSL? Which way is better?
I am doing this in my VS.
Any help would be greatly appreciated.
Thanks
you still need to supply your model normals, GLSL is just like the VP/FP in this regard.
and as long as your normals are unit length I'm 99% sure you shouldnt need to renormalise that equation either...
and as long as your normals are unit length I'm 99% sure you shouldnt need to renormalise that equation either...
Well isnt the normal matrix the upper left 3x3 matrix of the modelview inverse transpose? which SHOULD mean that its an orthonormal basis that contains only rotation.. right? So yes its magnitude should remain constant
hope that helps
-Dan
hope that helps
-Dan
Quote:Original post by _the_phantom_
you still need to supply your model normals, GLSL is just like the VP/FP in this regard.
and as long as your normals are unit length I'm 99% sure you shouldnt need to renormalise that equation either...
Ok, so leave my code alone to upload my normals to OpenGL then. So all I should have to do is pass my normal through the vertex shader to the fragment shader then? And use the normal in the fragment shader?
Quote:Original post by Ademan555
Well isnt the normal matrix the upper left 3x3 matrix of the modelview inverse transpose? which SHOULD mean that its an orthonormal basis that contains only rotation.. right? So yes its magnitude should remain constant
hope that helps
-Dan
?? Lost me on what you're getting at? :)
Quote:Original post by MARS_999
Ok, so leave my code alone to upload my normals to OpenGL then. So all I should have to do is pass my normal through the vertex shader to the fragment shader then? And use the normal in the fragment shader?
Well, you'll want to transform it by the normal matrix, but then you can just pass it down as a varying and use it in the fragment shader, yes
Ok, I think I am on to something working, I see my lighting changes when I move my camera around?? I didn't have this issue when I used a FP/VP??? Any ideas?
Quote:Original post by MARS_999
Ok, I think I am on to something working, I see my lighting changes when I move my camera around?? I didn't have this issue when I used a FP/VP??? Any ideas?
Hmmm, how can my lightposition be moving around when my camera is moving around shouldn't it stay still if I am not updating the glLightPosition???
The light position is transformed as if it were a vertex. You would want to specify it after you have applied the camera transformations.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement