Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
654 views
in Technique[技术] by (71.8m points)

c++ - Compute the vertex normals of a triangle mesh generated from heightmap (using CUDA)

I am currently dealing with the problem with vertex normals. I have a triangle mesh generated from a heightmap with uniform grid triangulation as shown in the figure(I am sorry it is drawn by hand, so not quite precise).

uniform grid triangulation

I know there are 2 ways to compute the vertex normals:

  1. Use a central difference filter directly on the 2D heightmap texture. This way is pretty easy to implement. (Generating a normal map from a height map?)

  2. Iterate all the triangles(faces). For each face, compute its face normal, and add it into each of the three vertex normals that the face contributes to. After then, do the normalization for all of them (cited from http://help.autodesk.com/view/3DSMAX/2015/ENU/?guid=__files_GUID_9B83270D_1D20_4613_AB35_5EE9832C162E_htm)

The first method can be parallelized with CUDA without a race condition. However, when I tried to implement the second method, I found that it is hard to avoid the problem. Because each vertex is normally shared by 6 triangles. So I would like to ask whether there is a solution that can avoid race condition but also preserve a good performance?

question from:https://stackoverflow.com/questions/65843097/compute-the-vertex-normals-of-a-triangle-mesh-generated-from-heightmap-using-cu

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...