feat(world-gen): larger biomes, smooth height blending, capped mountains; centralize tunables in Configuration

Terrain feel: biome regions ~10x larger (Voronoi cell size 96->960); terrain height now eases across biome borders via a Voronoi distance blend (smooth, and ~25x cheaper than the old 169-sample box blur); mountains capped to ~2/3 world height and gentled (ridged amplitude/frequency lowered), snow line lowered to match.

Centralization: ~27 world-gen/render tuning constants (biome amplitudes & frequencies, climate-noise frequencies/octaves, biome-selection thresholds, blend width, cell size, filler depth, snow line, camera near plane, spawn offset, overlay scale) hoisted from scattered literals into a region-organized, fully-commented Configuration. Configuration is threaded into NoiseSource, the biomes, BiomeRegistry, BiomeMap (+Classify), TerrainSampler, WorldGenerator (+BlockAt filler depth), and Camera via Player. Defaults equal the prior values, so generation is unchanged; worldgen tests updated for the new constructor signatures.
This commit is contained in:
MDietermann
2026-06-03 16:27:06 +02:00
parent 96b8fffcd4
commit e034d10339
18 changed files with 367 additions and 136 deletions

View File

@@ -1,3 +1,4 @@
using VoxelEngine.Core;
using VoxelEngine.World.Blocks;
namespace VoxelEngine.World.WorldGen.Biomes;
@@ -5,21 +6,23 @@ namespace VoxelEngine.World.WorldGen.Biomes;
public sealed class DesertBiome : IBiome
{
private readonly FastNoiseLite _detail;
private readonly Configuration _cfg;
public string Name => "Desert";
public SurfacePalette Surface { get; }
public DesertBiome(int seed, BlockRegistry blocks)
public DesertBiome(int seed, BlockRegistry blocks, Configuration cfg)
{
this._cfg = cfg;
this._detail = new FastNoiseLite(seed + 101);
this._detail.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
this._detail.SetFrequency(0.015f);
this._detail.SetFrequency(cfg.DesertDetailFrequency);
this.Surface = new SurfacePalette(blocks.Sand, blocks.Sand, blocks.Stone);
}
public float SampleHeight(NoiseSource noise, float worldX, float worldZ)
=> WorldConstants.SeaLevel + 16f * noise.Continent(worldX, worldZ)
+ 6f * this._detail.GetNoise(worldX, worldZ);
=> WorldConstants.SeaLevel + this._cfg.DesertContinentAmplitude * noise.Continent(worldX, worldZ)
+ this._cfg.DesertDetailAmplitude * this._detail.GetNoise(worldX, worldZ);
public IBlock TopBlock(int worldY) => this.Surface.Top;
}

View File

@@ -1,3 +1,4 @@
using VoxelEngine.Core;
using VoxelEngine.World.Blocks;
namespace VoxelEngine.World.WorldGen.Biomes;
@@ -5,21 +6,23 @@ namespace VoxelEngine.World.WorldGen.Biomes;
public sealed class ForestBiome : IBiome
{
private readonly FastNoiseLite _detail;
private readonly Configuration _cfg;
public string Name => "Forest";
public SurfacePalette Surface { get; }
public ForestBiome(int seed, BlockRegistry blocks)
public ForestBiome(int seed, BlockRegistry blocks, Configuration cfg)
{
this._cfg = cfg;
this._detail = new FastNoiseLite(seed + 103);
this._detail.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
this._detail.SetFrequency(0.03f);
this._detail.SetFrequency(cfg.ForestDetailFrequency);
this.Surface = new SurfacePalette(blocks.Grass, blocks.Dirt, blocks.Stone);
}
public float SampleHeight(NoiseSource noise, float worldX, float worldZ)
=> WorldConstants.SeaLevel + 24f * noise.Continent(worldX, worldZ)
+ 16f * this._detail.GetNoise(worldX, worldZ);
=> WorldConstants.SeaLevel + this._cfg.ForestContinentAmplitude * noise.Continent(worldX, worldZ)
+ this._cfg.ForestDetailAmplitude * this._detail.GetNoise(worldX, worldZ);
public IBlock TopBlock(int worldY) => this.Surface.Top;
}

View File

@@ -1,32 +1,34 @@
using VoxelEngine.Core;
using VoxelEngine.World.Blocks;
namespace VoxelEngine.World.WorldGen.Biomes;
public sealed class MountainsBiome : IBiome
{
private const int SnowLine = 384;
private readonly FastNoiseLite _ridged;
private readonly IBlock _stone;
private readonly IBlock _snow;
private readonly Configuration _cfg;
public string Name => "Mountains";
public SurfacePalette Surface { get; }
public MountainsBiome(int seed, BlockRegistry blocks)
public MountainsBiome(int seed, BlockRegistry blocks, Configuration cfg)
{
this._cfg = cfg;
this._ridged = new FastNoiseLite(seed + 102);
this._ridged.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
this._ridged.SetFractalType(FastNoiseLite.FractalType.Ridged);
this._ridged.SetFractalOctaves(4);
this._ridged.SetFrequency(0.01f);
this._ridged.SetFractalOctaves(cfg.MountainsRidgedOctaves);
this._ridged.SetFrequency(cfg.MountainsRidgedFrequency);
this._stone = blocks.Stone;
this._snow = blocks.Snow;
this.Surface = new SurfacePalette(blocks.Stone, blocks.Stone, blocks.Stone);
}
public float SampleHeight(NoiseSource noise, float worldX, float worldZ)
=> WorldConstants.SeaLevel + 40f * noise.Continent(worldX, worldZ)
+ 200f * this._ridged.GetNoise(worldX, worldZ);
=> WorldConstants.SeaLevel + this._cfg.MountainsContinentAmplitude * noise.Continent(worldX, worldZ)
+ this._cfg.MountainsRidgedAmplitude * this._ridged.GetNoise(worldX, worldZ);
public IBlock TopBlock(int worldY) => worldY >= MountainsBiome.SnowLine ? this._snow : this._stone;
public IBlock TopBlock(int worldY) => worldY >= this._cfg.MountainsSnowLine ? this._snow : this._stone;
}

View File

@@ -1,3 +1,4 @@
using VoxelEngine.Core;
using VoxelEngine.World.Blocks;
namespace VoxelEngine.World.WorldGen.Biomes;
@@ -5,21 +6,23 @@ namespace VoxelEngine.World.WorldGen.Biomes;
public sealed class PlainsBiome : IBiome
{
private readonly FastNoiseLite _detail;
private readonly Configuration _cfg;
public string Name => "Plains";
public SurfacePalette Surface { get; }
public PlainsBiome(int seed, BlockRegistry blocks)
public PlainsBiome(int seed, BlockRegistry blocks, Configuration cfg)
{
this._cfg = cfg;
this._detail = new FastNoiseLite(seed + 100);
this._detail.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
this._detail.SetFrequency(0.02f);
this._detail.SetFrequency(cfg.PlainsDetailFrequency);
this.Surface = new SurfacePalette(blocks.Grass, blocks.Dirt, blocks.Stone);
}
public float SampleHeight(NoiseSource noise, float worldX, float worldZ)
=> WorldConstants.SeaLevel + 24f * noise.Continent(worldX, worldZ)
+ 8f * this._detail.GetNoise(worldX, worldZ);
=> WorldConstants.SeaLevel + this._cfg.PlainsContinentAmplitude * noise.Continent(worldX, worldZ)
+ this._cfg.PlainsDetailAmplitude * this._detail.GetNoise(worldX, worldZ);
public IBlock TopBlock(int worldY) => this.Surface.Top;
}