Normals, GLSL, FP/VP

Started by
17 comments, last by MARS_999 18 years, 9 months ago
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.

/* first transform the normal into eye space and normalize the result */
	normal = normalize(gl_NormalMatrix * gl_Normal);


Any help would be greatly appreciated. Thanks
Advertisement
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...
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
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
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? :)
Dont need to normalize, supporting what _the_phantom_ said

hope that helps
-Dan
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
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