I am trying to add faces to a terrain mesh to close it into a “solid” object. I am projecting the mesh vertices into the bottom plane and adding the faces based on the edges of the original mesh. Afterward, I add the vertical faces based on the naked edges from the original.
the code of this last step is copied here:
for (int i = 0; i <= mTopologyEdges.Count - 1; i += 1)
{
u[0] = mTopologyVerices.MeshVertexIndices(mTopologyEdges.GetTopologyVertices(i).I)[0];
u[1] = mTopologyVerices.MeshVertexIndices(mTopologyEdges.GetTopologyVertices(i).J)[0];
The mesh ends up rendering with a gradient across the vertical axis. I am assuming this has to do with vertex normals? but I am not sure. Does anyone have any idea on how to fix this?
I am hoping to get something like the left model here as opposed to the right one
Thanks, guys! Actually in this particular case M.Vertices.CombineIdentical(true, true) would in fact cause this same rendering problem and perhaps ruin a properly rendered mesh. The issue with the mesh I was creating was that it did not have identical vertices to begin with. Notice how a simple mesh box with 8 corners will need 24 vertices(right) to render correctly instead of just 8(left).
To fix my problem I had to duplicate the corner vertices and assign the proper normals to them. you could run M.Vertices.CombineIdentical(FALSE, true) at the end to clean things up but have to make sure you are not ignoring vertices with different vertex normals.