Jump to content
  • Advertisement
Sign in to follow this  
conman

generate smooth normals

This topic is 4884 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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Supernat02: I read your reply, when I comitted this one, I will give it a try!

Thanks again,
Constantin

Share this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!