#### Archived

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

# Another question about normals

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

## Recommended Posts

allright, I figured out how to find the normal for a face. But I have just one question - what if a vertex shares two or more faces with different normals, how would I figure out the normal for that vertex? For example, I have a box that contains 8 verts, and each one of those verts shares 3 faces that contain different normals (since one vert is at each corner). All the examples I have come across make their boxes so that each face has its own verts, but those boxes contain 24 verts which is 16 more than my box and would slow performance down on larger models. thanks

##### Share on other sites
If you''re using triangle strips or triangle fans, then your triangles do indeed share normals, as well as vertices, in which case you''ll probably want to average out the face normals for the faces that meet at that point. The resulting averaged normals are called ''vertex normals''.

This, combined with gouraud shading, will give you very smooth shading across an object. Individual faces will not be clearly defined from the shading (this is typical of what you will see in most games). If you want sharp edges to your triangles, either use triangle lists and specifiy the face normal for all three normals, or switch to flat shading.

With triangles strips/fans D3D assumes you are sending it vertex normals. As for how to average out the face normals, you can simple take the mean (average) of the individual x,y and z components of the face normals. The difficult bit is finding which faces share vertices.

##### Share on other sites
well .. i dont know exactly, but i have code to find a normal for a triangle.

  void CPoligon::ComputeNormal(){ D3DXVECTOR3 vec1; D3DXVECTOR3 vec2; ComputeVector(vec1,m_Vertex[2].position,m_Vertex[1].position); ComputeVector(vec2,m_Vertex[3].position,m_Vertex[1].position); D3DXVec3Cross(&m_Normal,&vec1,&vec2); D3DXVec3Normalize(&m_Normal,&m_Normal);}void CPoligon::ComputeVector(D3DXVECTOR3 & vecRet,D3DXVECTOR3 &vec1,D3DXVECTOR3 &vec2){ vecRet.x = vec1.x - vec2.x; vecRet.y = vec1.y - vec2.y; vecRet.z = vec1.z - vec2.z;}

m_Vertex is an array of 3 vertex''s which forms a triangle.
i used d3dx for some functions

{ Stating the obvious never helped any situation !! }

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 47
• ### Forum Statistics

• Total Topics
632636
• Total Posts
3007574
• ### Who's Online (See full list)

There are no registered users currently online

×