Front and back of a surface with lighting
I''ve been trying stuff out with lighting and reading up on it and for some reason when my light gets near the front of the surface it gets darker , but the back gets brighter , is the back the side that we are suppose to be using , or do I have something wrong , Thanks
Alex
Sounds like your normal is facing the wrong way.
Death of one is a tragedy, death of a million is just a statistic.
Death of one is a tragedy, death of a million is just a statistic.
I think I''ve missed something about normals in opengl , I know in math the normal is a line that is perpendicular to the plain so there for there would be 2 points or 1 point on the plain and one out of the front , what I''ve learned about opengl its suppose to be a point on the plane
there for if you had this plane
glVertex3f(-5,0,-5);
glVertex3f( 5,0,-5);
glVertex3f( 5,2,-5);
glVertex3f(-5,2,-5);
the normal would be
glNormal3f(0,1,-5);
the code afterwards would be
glNormal3f(0,1,-5);
glVertex3f(-5,0,-5);
glVertex3f( 5,0,-5);
glVertex3f( 5,2,-5);
glVertex3f(-5,2,-5);
if this is incorrect where should the normal be
OR
if this is the front then how would I get the normal to switch it for the back
thanks
Alex
there for if you had this plane
glVertex3f(-5,0,-5);
glVertex3f( 5,0,-5);
glVertex3f( 5,2,-5);
glVertex3f(-5,2,-5);
the normal would be
glNormal3f(0,1,-5);
the code afterwards would be
glNormal3f(0,1,-5);
glVertex3f(-5,0,-5);
glVertex3f( 5,0,-5);
glVertex3f( 5,2,-5);
glVertex3f(-5,2,-5);
if this is incorrect where should the normal be
OR
if this is the front then how would I get the normal to switch it for the back
thanks
Alex
quote:
glVertex3f(-5,0,-5);
glVertex3f( 5,0,-5);
glVertex3f( 5,2,-5);
glVertex3f(-5,2,-5);
the normal would be
glNormal3f(0,1,-5);
the code afterwards would be
glNormal3f(0,1,-5);
glVertex3f(-5,0,-5);
glVertex3f( 5,0,-5);
glVertex3f( 5,2,-5);
glVertex3f(-5,2,-5);
if this is incorrect where should the normal be
OR
if this is the front then how would I get the normal to switch it for the back
thanks
Alex
no the normal would be either (0,0,1) or (0,0,-1) depending on which way you want the normal to face...you'd probably want (0,0,1) cause then it would face the positive Z direction
normals are always between -1 and 1
A CRPG in development...
Need help? Well, go FAQ yourself.
"I'm gay, please convert me." - Nes8bit
[edited by - Nazrix on June 27, 2002 1:54:38 AM]
you get the normal by taking what''s called the cross product of the 3 points of a triangle and normalizing it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement