private void GenerateHeightmap()
{
ReportProgress( 10, "Heightmap: Priming" );
heightmap = new float[args.MapWidth, args.MapLength];
noise.PerlinNoise( heightmap, args.FeatureScale, args.DetailScale, args.Roughness, 0, 0 );
if ( args.UseBias && !args.DelayBias ) {
ReportProgress( 2, "Heightmap: Biasing" );
Noise.Normalize( heightmap );
ApplyBias();
}
Noise.Normalize( heightmap );
if ( args.LayeredHeightmap ) {
ReportProgress( 10, "Heightmap: Layering" );
// needs a new Noise object to randomize second map
float[,] heightmap2 = new float[args.MapWidth, args.MapLength];
new Noise( rand.Next(), NoiseInterpolationMode.Bicubic ).PerlinNoise( heightmap2, 0, args.DetailScale, args.Roughness, 0, 0 );
Noise.Normalize( heightmap2 );
// make a blendmap
blendmap = new float[args.MapWidth, args.MapLength];
int blendmapDetailSize = ( int )Math.Log( Math.Max( args.MapWidth, args.MapLength ), 2 ) - 2;
new Noise( rand.Next(), NoiseInterpolationMode.Cosine ).PerlinNoise( blendmap, 3, blendmapDetailSize, 0.5f, 0, 0 );
Noise.Normalize( blendmap );
float cliffSteepness = Math.Max( args.MapWidth, args.MapLength ) / 6f;
Noise.ScaleAndClip( blendmap, cliffSteepness );
Noise.Blend( heightmap, heightmap2, blendmap );
}
if ( args.MarbledHeightmap ) {
ReportProgress( 1, "Heightmap: Marbling" );
Noise.Marble( heightmap );
}
if ( args.InvertHeightmap ) {
ReportProgress( 1, "Heightmap: Inverting" );
Noise.Invert( heightmap );
}
if ( args.UseBias && args.DelayBias ) {
ReportProgress( 2, "Heightmap: Biasing" );
Noise.Normalize( heightmap );
ApplyBias();
}
Noise.Normalize( heightmap );
}