After patching together the crater (described previously), I noticed a deformation at the edges of the crater's upturn. Initially, I gave it little thought and blamed it on a side-effect associated with terrains with sharp edges.
However, the subconscious mind is apparently very persistent, and a possible fix dawned on me. The four vertexes used to create the two triangles for the terrain do not (in all likelihood) line up to form a plane. The quadrilateral create by the points A,B,C and D is divided into two triangles using either the diagonal AC or the diagonal BD. In the terrain construction, the same diagonal is always chosen. The picture above illustrates the consequence -- the edges of the crater is very jagged.
Instead of a fixed choice, a better result is obtained when the diagonal is chosen with more care. Here is the rule I applied: take the diagonal that is the highest. This means that the quadrilateral will be always be convex (as seen from the outside) -- and some concave aspects of the generated terrain will disappear. In other words the terrain will have less jagged edges. To compute the highest diagonal I take the diagonal that has the largest sum of the Y component of its vertexes. Other methods also seem reasonable: for instance take the diagonal with the highest Y.
The second picture shows the same view as the first using the largest sum method. Definitely a noticeable improvement.
No comments:
Post a Comment