void GenerateHeightMap(DiamondSquare.CornerData corners, double range, double h, double amplify)
{
// +1 for diamond square
var heightMap = new ArrayGrid2D <double>(m_size.Width + 1, m_size.Height + 1);
double min, max;
DiamondSquare.Render(heightMap, corners, range, h, m_random, out min, out max);
Parallel.For(0, m_size.Height, y =>
{
double d = max - min;
for (int x = 0; x < m_size.Width; ++x)
{
var v = heightMap[x, y];
// normalize to 0.0 - 1.0
v = (v - min) / d;
// amplify
v = Math.Pow(v, amplify);
// adjust
v *= m_size.Depth / 2;
v += m_size.Depth / 2 - 1;
m_data.SetSurfaceLevel(x, y, MyMath.Round(v));
}
});
}