[Algorithms] Terrain Normals
Brought to you by:
vexxed72
From: Pai-Hung C. <pa...@ac...> - 2000-08-14 06:28:31
|
Hi, I've written a routine to read a bitmap heightfield and construct a terrain mesh from it. I partition each set of four pixels into two triangles along the upper-right-to-lower-left diagonal line. Therefore, for example, a 128 x 128 bitmap will produce (128-1) x (128-1) x 2 = 32258 triangles using my method. For each triangle I caculate its unit face normal. For each vertex of a triangle, I calculate its vertex normal by adding and averaging the face normals of all triangles that share the vertex (in my case a vertex can be shared by at most six triangles and at least one triganle) and then normalize the averaged normal, which is used in redering. My problem is that there are some *horizontal dimmed banding* effects along the triangle edges of the mesh when rendering in D3D with light cast on it. Also, there are very visible dimmed seams between triangles when light is cast on it. All these artifacts seem to manifest only when light is cast in large angles (i.e. not directly). Is it because the arrangement of triangles in my mesh is too *uniform* (actually they are extremely uniform)? Or is my calculation of vertex normals incorrect? Thanks in advance, Pai-Hung Chen |