2
votes

Model

I've got a model that I've loaded from a JSON file (stored as each tile /w lots of bools for height, slope, smooth, etc.). I've then computed face normals for all of it's faces and copied them to each of their verticies. What I now want to do (have been trying for days) is to smooth the vertex normals, in the simplest way possible. What I'm trying to do is set each vertex normal to a normalized sum of it's surrounding face normals. Now, my problem is this:

The two circled vertices should end up with perfectly mirrored normals. However, the one on the left has 2 light faces and 4 dark faces. The one on the right has 1 light face and 6 dark faces. As such, they both end up with completely different normals.

What I can't work out is how to do this properly. What faces should I be summing up? Or perhaps there is a completely different method I should be using? All of my attempts so far have come up with junk and / or consisted of hundreds of (almost certainly pointless) special cases.

Thanks for any advice, James

Edit: Actually, I just had a thought about what to try next. Would only adding a percentage of each triangle based on it's angle work (if that makes sense). I mean, for the left, clockwise: x1/8, x1/8, x1/4, x1/8, x1/8, x1/4 ??? And then not normalize it?

That solution worked wonderfully. Final result:smoothed

1
In my experience, it can be enormously helpful to add some debug drawing routines in order to visualize various aspects of your geometry. Try rendering your normals at each face and / or vertex and see if it helps point out the issue.Lee Adams
You beat me to an answer with your edit. I was going to propose using the angle between the adjacent edges as the weight of each normal. 15 minutes isn't much time to let people read the question and come up with an answer. ;)Reto Koradi
Sorry, I thought of it while staring at the picture. It seems that doing scribbles like that is helpful :)Jagoly
@Spektre: That's not a duplicate. The other question/answer is exactly what the OP tried, and that did not produce good results. The goal here is to find something that works better for this case.Reto Koradi

1 Answers

0
votes

Based on the image it looks like you might want to take the average of all unique normals of all adjacent faces. This avoids double counting faces with the same normal.