Jump to content
  • Advertisement


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


Best way to generate Normals?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently able to generate vertex normals using the triangle normal calculation. The problem with this is that it''s giving me FLAT shading on my terrain because the entire triangle is shaded with all the vertices having the same normal. I''ve been playing around with the algorythm to try and use points outside of the vertex''s triangle to generate different normals for each vertex and achieve a SMOOTH shading. What I''ve got looks much better, but it''s still not perfect - I''m taking the average of two inclines from a quad around the vertex. Is there a faster and cheaper way to get the right normals?

Share this post

Link to post
Share on other sites
Usual way to generate vertex normals is to average the normals of all triangles using a point.

/\ C / \
/ \ / \
/ A \ / D \
\ B /
\ /

[assuming the ASCII art came out] Consider the above "mesh". It has 4 triangles, A,B,C and D and 6 vertices (1-6).

Vertex 1 is shared by polygons A and B so its vertex normal is simply the average of the FACE normals of both A and B. Doing the same for the other vertices:

v[1].n = (A.n + B.n) / 2
v[2].n = (A.n + C.n) / 2
v[3].n = (A.n + B.n + C.n + D.n / 4
v[4].n = B.n / 1
v[5].n = (C.n + D.n) /2
v[6].n = D.n / 1

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites
I''m new at this, so i was wondering about something i read in "Beginning Direcr3D Game Programming" bye W. F. Engel. And on pg 29 when he introduces normals he has a tip that says:

"Direct3D applications do not need to specify face normals; the system calculates them automatically when they are needed".

Now, like i said, being new at this, i thought that sounded like an incredible feature. Then i noticed he specifies them in his own code later. So i was wondering what the deal is with how to do normals the "right" way.


Share this post

Link to post
Share on other sites
Guest Anonymous Poster
it does compute FACE normals, not vertex normals. drawing in the D3DSHADE_FLAT mode does this. You need to compute the normals in the D3DSHADE_GOURAUD mode, which will give you the smooth look. if you need to have a smooth model with some sharp/flat parts, then you need to have duplicate the verts at the transition, so they can have different normals. The SDK explains it better then me, but maybe you understand what i''m talking about, paste this into the index help..."Face and Vertex Normal Vectors"

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!