I'm creating my own terrain tiling system for the iPhone so I don't have "SetNeighbours" or anything like that. I'm working in raw meshes. As such the normals near the edge of my meshes are screwed up.
Any way I can set the normals for my triangles manually?
Something like that should do it if you have a script-made mesh and want to recalculate the normals.
EDIT: Yes, you can edit the normals by hand, too:
I hope that helps - if you need help for the calculation itself, just comment; I will see what I can do (you could also take a look at this first - does exactly what you want, I think).
Best way i found using procedural terrains, just get 2 points near the vertex using the same info you had to get the vertex height, it ll give you 3 points to cross product normal height and smooth shadows also. if you use 4 points around the vertex it may give you better results on peaks normals. works with hi res terrain height data. seamless. better quality normals.
there are various ways to calculate normals on the edges of the tiles. The question is, which one is easier, and which one is faster.
You can use the height map/procedural data to sample the points around the edge vertices and construct a normal from that. slow method.
You can use a separate mesh that is not visible and that is larger so that the visible tiles, and then you apply all the vertex/normal calculations to the hidden tile, and then copy the normals and the vertices from the hidden tile to the visible ones. I expect this is the slowest method.
The fastest by far method, I'm not sure how accurate it is I haven't tried it it should be hundred percent accurate, is that you go through the vertices of edges, and you will find that for a 10 x 10 plane, vertex 1 is on the same point as vertex 91 for the plane next to it, because vertices 0 to 10 is the south edge, and 90 to 100 is the North edge, and all the East ones all finish with 0, and the West ones all finish with 9. So when you have to vertices on the same points you can add the normal of both and divide by 2 to average it and get the actual normal of that point which I think should be correct. it should be true for the edges and corners.
What you can also do is rotate each tile by 90 so that all the edge vertices correspond one-to-one with each other in the array indices, and generate the height map data using transform point.
also go through edge vertices' normals for adjoining mesh and average normals that share same vertex position.
Triangles don't have normals. Vertices do.
answered Oct 29 '10 at 10:20 PM