• ### What is your GameDev Story?

#### Archived

This topic is now archived and is closed to further replies.

This topic is 5824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok, I''m drawing Quad Strips in my program, and I''m specifying the normals for them, but what I''m wondering about is if I can do it like this: glNormal3f(Normal[0].x, Normal[0].y, Normal[0].z); glVertex3f(Vertex[0].x, Vertex[0].y, Vertex[0].z); glVertex3f(Vertex[1].x, Vertex[1].y, Vertex[1].z); glVertex3f(Vertex[2].x, Vertex[2].y, Vertex[2].z); glNormal3f(Normal[1].x, Normal[1].y, Normal[1].z); glVertex3f(Vertex[3].x, Vertex[3].y, Vertex[3].z); Or if I just use the same normal for the whole Quad Strip... Any help is greatly appreciated!

##### Share on other sites
Rememer that OpenGL is a (finite) state machine. So normal will be used for all vertices processed until you send a new one.

You should never let your fears become the boundaries of your dreams.

##### Share on other sites
Yes, thank you DarkWing, but I''m already aware of that. But what I wanted to know is if the second normal counts for the second quad... Because of that after the three first vertices, every new vertex specifies a new quad...

##### Share on other sites
I think each normal counts for only the vertex not a whole quad. You can then have a quad with 4 different normals if you want smoother lighting.

##### Share on other sites
Thank you Xiros! But is there really a way to calculate normals per vertex?? If there is I would really like to know. So please, if you have any tutorials, references, etc...

##### Share on other sites
a vertex has no normal, you can only get the normal from a plane (3 points). to do that just take the cross product of two vectors (two sides of a triangle).

##### Share on other sites
If you want your object to appear smooth (e.g. a sphere), then you need to calculate an average normal from the vectors of the neighboring polygon edges.

If you want it to appear angular (e.g. a cube) then for each vertex have it calculated as the cross product of two of the polygons edges.

I have not done much 3D, and one thing I am curious about is how the artist controls the normals in a model - I have made a 3d model before but at no point did I seem to have direct control of the vertice normals, so how could the program possibly know what was supposed to be a smooth edge and what was supposed to be a angular edge?

One way I thought is that if it is a large angle (say 150 degs)between edges then the normal would be averaged, otherwise it is normal to the polygon face, is this correct?

##### Share on other sites
quote:
Original post by xiros
I think each normal counts for only the vertex not a whole quad. You can then have a quad with 4 different normals if you want smoother lighting.

I am possibly mistaken here, but..If you are using index buffers, then you can only have one averaged normal, and all the faces surrounding it will be smooth, and even if you weren''t, you would set all the vertice normals to the same direction to make it appear smooth (how exactly this would be done without an index buffer I dont know).

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 13
• 9
• 9
• 15
• ### Forum Statistics

• Total Topics
634076
• Total Posts
3015353
×