# generate smooth normals

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

## Recommended Posts

Hi, I am in the need to manipulate a mesh (f.e. the Mesh.Box) in a way that the normals of each vertex point in the direction that is the medium of all face normals of faces the vertex is associated with.

| n1
|
--------- v1/v2 ----- n2
|
|
|
|

should be converted into:

/ n
/
--------- v
|
|
|
|


Is there maybe a easy D3D function to do something like this. I guess its a kind of normal smoothing. Or do I have to invent an algorithm myself? Thanks, Constantin

##### Share on other sites
If I understand you correctly, you just need to add the normals together and renormalize the result. So for each vertex normal, you normalize the sum of normals from all of it's polygons.

I don't beleive there is a D3DX method to achieve this.

##### Share on other sites
I'm not sure of this, but if there is a D3DX function that sorts out tangents for each vertex, you could manipulate a vertex once the tangent is known.

ace

##### Share on other sites
So you are just trying to compute per vertex normals?

##### Share on other sites
I think the function you are looking for is D3DXComputeNormals. Pass in an ID3DXMesh and any adjacency information you might have (or NULL).

##### Share on other sites
Thanks for your replies, I will try to make clearer what I need :)

I have a existing mesh, for example the teapot mesh of DirectX.
It contains already normal information per vertex, but I want to smooth these.

I want a vertex normal pointing in the direction that is the average of each face normal of faces it belongs to.

What makes it a little bit complicated is, that meshes often contain the same vertex multiple times, each vertex belongs to another face.

So for every vertex I have to find vertices at the same place, find all faces that belong to all this vertices, calculate an average normal and assign it to all this vertices.

I implemented a function doing all this, but if there is something existing I can use it would be also perfect.

Thanks again,
Constantin

##### Share on other sites
I haven't used *.x files much, but because they are converted from *.3ds files I asume that it loads the *.3ds normals (and at the same time computes normals by smoothing groups), so let the model editor (max, etc.) handle it for you.

##### Share on other sites
Arex:
Quote:
 so let the model editor (max, etc.) handle it for you.

Yes that is definitively a solution.

But I tried D3DXComputeNormals, as Supernat02 suggested and it is exactly the solution to my problem!

Thanks to all!
Constantin

• ### What is your GameDev Story?

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

• 28
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634103
• Total Posts
3015539
×