Sign in to follow this  

Computing Vertex Normals

This topic is 4108 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'm trying to figure out the best way to calculate surface normals for a surface. I had a vague recollection that the way you do this is calculate the normals for at the triangles that intersect at that vertex and combine them. In my situation, I have a fairly regular mesh that is almost like a grid. Each vertex on the grid intersects with six other triangles. I can easily determine the six vertices surrounding the center vertex that. The main complication is that the triangles are much closer to icosolese triangles than right triangles since they are sub-divided from the faces of an icosahedron. I'm not sure if that changes the calculation. My question is, is there an algorithm to take these seven vertices and compute the vertex normal for the one at the center? or do I have to calculate the triangle normals first? I'm still not sure what tangent space is, or how normal mapping is going to affect the problem, or if this article has all the answers: http://www.gamedev.net/reference/articles/article2264.asp This Post http://groups.google.com/group/microsoft.public.win32.programmer.directx.graphics/browse_thread/thread/8737cbab52062a98/ebaf84fa5cfe5aaf?lnk=gst&q=compute+normals&rnum=3#ebaf84fa5cfe5aaf suggests that I can "Make a tangent vector from neighbours in the X direction, and one from neighbours in the Z direction (or Y of your plane is XY), then take the cross product and normalize." "Cross product produces a vector that is perpendicular to the two input vectors. Point left index finger horizontally in front of you - that is tangent in X direction; lay right index finger over left finger and point away from you - that is tangent in Z direction. Visualize a third finger (or get a friend to help, or use other body part) pointing up from the cross-over point that is right-angles to both of your fingers... this is the normal vector that would be produced. " That sounds very close to what I'm trying to do, though it seems to me that I have three pairs of neighbors. Essentially, I have a fractally generated globe. I don't use perlin noise or any kind of linear function to generate the terrain; I use a recursive subdivision algorithm. What I want to do is burn the detail data into a texture, so I can display the globe at a lower detail. I was planning on using render-to-texture for this. Since it's not a function I can easily put an x/y value into, the only way for me to avoid the render-to-texture technique would be a sort of raytracing/raycasting method per pixel to generate the texture image, but it seems that the GPU would be way faster to do this on. What are the best resources for a render normal map to texture type technique? I found this one: http://www.gamedev.net/community/forums/topic.asp?topic_id=348397&whichpage=1�

Share this post


Link to post
Share on other sites
im assuming youre still trying to compute the vertex normals for your meshes. at the moment im having the same problem but i know the solution for you. yes you do need to calculate all of the face normals first (this is MUCH easier to do). then run through a list of your vertices and average the normals of the attached faces. if you have smoothing groups involved, then check and see if the neighboring face is a part of the same group. if it is, then average it, if not, dont average it.

Share this post


Link to post
Share on other sites
I realized yesterday that if I stop thinking of my icosahedron as 20 triangles, and instead break it into 10 curved quadrilateral patches, a bunch of things get easier for me. Now my fractal generator subdivides squares instead of triangles and its a lot more efficient.

I have two problems at this point.
1) How to generate normals for smooth shaded terrain patches without creating seams on the borders between patches. There's no way to pass the edge information into the DirectX ComputeNormals function, so I need to implement my own algorithm. I think the simple algorithm here will work fine:
http://www.lighthouse3d.com/opengl/terrain/index.php?normals

2) I want to render highly detailed patches to texture. I'm looking for an algorithm to render output to a normal map. I'm also considering that I don't really need a normal map for the detailed terrain because the light source (the sun) doesn't move all that much.

Share this post


Link to post
Share on other sites

This topic is 4108 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this