after optimization the loop should look as (IMHO):
for (int i = 0; i < numMapVerts; i++)
{
IPoint3 vertex = mesh.GetVert(i);
mapVerts[i].X = 1; // if you need to double-check it
if (vertex.Z > HeightThreshold)
{
mapVerts[i].Y = Math.Max(0, mapVerts[i].Y - FadeInValue);
//mapVerts[i].Z = Math.Max(0, mapVerts[i].Z - FadeInValue); // if it's not a grey scale
}
else
{
mapVerts[i].Y = Math.Min(1, mapVerts[i].Y + FadeInValue);
//mapVerts[i].Z = Math.Min(1, mapVerts[i].Z + FadeInValue); // if it's not a grey scale
}
mapVerts[i].Z = mapVerts[i].Y; // if it's a grey scale
}
i believe we can do color assignment in place. and after compilation Math.Min or Math.Max is exactly the same as one comparison and one assignment.