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;
using VoxelEngine.World.WorldGen;
using Xunit;
@@ -9,38 +10,38 @@ public class BiomeMapTests
private static (BiomeMap map, BiomeRegistry biomes) Build(int seed = 42)
{
var blocks = new BlockRegistry();
var biomes = new BiomeRegistry(seed, blocks);
var noise = new NoiseSource(seed);
var biomes = new BiomeRegistry(seed, blocks, new Configuration());
var noise = new NoiseSource(seed, new Configuration());
var cells = new VoronoiCells(seed, 96f);
return (new BiomeMap(noise, cells, biomes), biomes);
return (new BiomeMap(noise, cells, biomes, new Configuration()), biomes);
}
[Fact]
public void Classify_HighElevation_IsMountains()
{
var (_, biomes) = Build();
Assert.Same(biomes.Mountains, BiomeMap.Classify(0f, 0.5f, 0f, biomes));
Assert.Same(biomes.Mountains, BiomeMap.Classify(0f, 0.5f, 0f, biomes, new Configuration()));
}
[Fact]
public void Classify_HotLowElevation_IsDesert()
{
var (_, biomes) = Build();
Assert.Same(biomes.Desert, BiomeMap.Classify(0.5f, 0f, 0f, biomes));
Assert.Same(biomes.Desert, BiomeMap.Classify(0.5f, 0f, 0f, biomes, new Configuration()));
}
[Fact]
public void Classify_TemperateWooded_IsForest()
{
var (_, biomes) = Build();
Assert.Same(biomes.Forest, BiomeMap.Classify(0f, 0f, 0.5f, biomes));
Assert.Same(biomes.Forest, BiomeMap.Classify(0f, 0f, 0.5f, biomes, new Configuration()));
}
[Fact]
public void Classify_ColdLow_IsPlains()
{
var (_, biomes) = Build();
Assert.Same(biomes.Plains, BiomeMap.Classify(-0.9f, 0f, 0f, biomes));
Assert.Same(biomes.Plains, BiomeMap.Classify(-0.9f, 0f, 0f, biomes, new Configuration()));
}
[Fact]

View File

@@ -1,3 +1,4 @@
using VoxelEngine.Core;
using VoxelEngine.World.Blocks;
using VoxelEngine.World.WorldGen;
using Xunit;
@@ -10,7 +11,7 @@ public class BiomeTests
public void Desert_TopAndFiller_AreSand()
{
var blocks = new BlockRegistry();
var biomes = new BiomeRegistry(42, blocks);
var biomes = new BiomeRegistry(42, blocks, new Configuration());
Assert.Equal("Sand", biomes.Desert.Surface.Top.Name);
Assert.Equal("Sand", biomes.Desert.Surface.Filler.Name);
}
@@ -19,7 +20,7 @@ public class BiomeTests
public void Mountains_UseSnowAboveSnowLine_StoneBelow()
{
var blocks = new BlockRegistry();
var biomes = new BiomeRegistry(42, blocks);
var biomes = new BiomeRegistry(42, blocks, new Configuration());
Assert.Equal("Stone", biomes.Mountains.TopBlock(200).Name); // below snow line
Assert.Equal("Snow Block", biomes.Mountains.TopBlock(420).Name); // above snow line (384)
}
@@ -28,7 +29,7 @@ public class BiomeTests
public void Plains_TopBlock_IsGrass_RegardlessOfHeight()
{
var blocks = new BlockRegistry();
var biomes = new BiomeRegistry(42, blocks);
var biomes = new BiomeRegistry(42, blocks, new Configuration());
Assert.Equal("Grass", biomes.Plains.TopBlock(40).Name);
Assert.Equal("Grass", biomes.Plains.TopBlock(120).Name);
}
@@ -37,8 +38,8 @@ public class BiomeTests
public void SampleHeight_IsDeterministic()
{
var blocks = new BlockRegistry();
var biomes = new BiomeRegistry(42, blocks);
var noise = new NoiseSource(42);
var biomes = new BiomeRegistry(42, blocks, new Configuration());
var noise = new NoiseSource(42, new Configuration());
float h1 = biomes.Mountains.SampleHeight(noise, 100f, 200f);
float h2 = biomes.Mountains.SampleHeight(noise, 100f, 200f);
Assert.Equal(h1, h2);

View File

@@ -1,3 +1,4 @@
using VoxelEngine.Core;
using VoxelEngine.World.WorldGen;
using Xunit;
@@ -8,8 +9,8 @@ public class NoiseSourceTests
[Fact]
public void SameSeed_SameCoord_IsDeterministic()
{
var a = new NoiseSource(42);
var b = new NoiseSource(42);
var a = new NoiseSource(42, new Configuration());
var b = new NoiseSource(42, new Configuration());
Assert.Equal(a.Continent(10f, 20f), b.Continent(10f, 20f));
Assert.Equal(a.Temperature(10f, 20f), b.Temperature(10f, 20f));
}
@@ -17,7 +18,7 @@ public class NoiseSourceTests
[Fact]
public void Output_InMinusOneToOneRange()
{
var n = new NoiseSource(7);
var n = new NoiseSource(7, new Configuration());
for (int i = 0; i < 200; i++)
{
float c = n.Continent(i * 3.1f, i * 1.7f);

View File

@@ -1,3 +1,4 @@
using VoxelEngine.Core;
using VoxelEngine.World.Blocks;
using VoxelEngine.World.WorldGen;
using Xunit;
@@ -9,11 +10,11 @@ public class TerrainSamplerTests
private static TerrainSampler Build(int seed = 42)
{
var blocks = new BlockRegistry();
var biomes = new BiomeRegistry(seed, blocks);
var noise = new NoiseSource(seed);
var biomes = new BiomeRegistry(seed, blocks, new Configuration());
var noise = new NoiseSource(seed, new Configuration());
var cells = new VoronoiCells(seed, 96f);
var map = new BiomeMap(noise, cells, biomes);
return new TerrainSampler(noise, map);
var map = new BiomeMap(noise, cells, biomes, new Configuration());
return new TerrainSampler(noise, map, new Configuration());
}
[Fact]

View File

@@ -15,8 +15,8 @@ public class WorldGeneratorTests
public void BlockAt_AboveTerrainAndSea_IsAir()
{
var blocks = Blocks;
var biomes = new BiomeRegistry(1, blocks);
ushort id = WorldGenerator.BlockAt(300, surfaceHeight: 290, biomes.Plains, blocks);
var biomes = new BiomeRegistry(1, blocks, new Configuration());
ushort id = WorldGenerator.BlockAt(300, surfaceHeight: 290, biomes.Plains, blocks, fillerDepth: 3);
Assert.Equal(blocks.Air.Id, id); // 300 > 290 (above surface) and 300 > SeaLevel(256)
}
@@ -24,8 +24,8 @@ public class WorldGeneratorTests
public void BlockAt_AboveTerrainBelowSea_IsWater()
{
var blocks = Blocks;
var biomes = new BiomeRegistry(1, blocks);
ushort id = WorldGenerator.BlockAt(60, surfaceHeight: 50, biomes.Plains, blocks);
var biomes = new BiomeRegistry(1, blocks, new Configuration());
ushort id = WorldGenerator.BlockAt(60, surfaceHeight: 50, biomes.Plains, blocks, fillerDepth: 3);
Assert.Equal(blocks.Water.Id, id); // 60 > 50 but 60 <= SeaLevel(64)
}
@@ -33,8 +33,8 @@ public class WorldGeneratorTests
public void BlockAt_Surface_IsBiomeTop()
{
var blocks = Blocks;
var biomes = new BiomeRegistry(1, blocks);
ushort id = WorldGenerator.BlockAt(70, surfaceHeight: 70, biomes.Desert, blocks);
var biomes = new BiomeRegistry(1, blocks, new Configuration());
ushort id = WorldGenerator.BlockAt(70, surfaceHeight: 70, biomes.Desert, blocks, fillerDepth: 3);
Assert.Equal(blocks.Sand.Id, id);
}
@@ -42,8 +42,8 @@ public class WorldGeneratorTests
public void BlockAt_FillerBand_IsBiomeFiller()
{
var blocks = Blocks;
var biomes = new BiomeRegistry(1, blocks);
ushort id = WorldGenerator.BlockAt(68, surfaceHeight: 70, biomes.Plains, blocks);
var biomes = new BiomeRegistry(1, blocks, new Configuration());
ushort id = WorldGenerator.BlockAt(68, surfaceHeight: 70, biomes.Plains, blocks, fillerDepth: 3);
Assert.Equal(blocks.Dirt.Id, id); // within 3 of surface
}
@@ -51,8 +51,8 @@ public class WorldGeneratorTests
public void BlockAt_Deep_IsStone()
{
var blocks = Blocks;
var biomes = new BiomeRegistry(1, blocks);
ushort id = WorldGenerator.BlockAt(40, surfaceHeight: 70, biomes.Plains, blocks);
var biomes = new BiomeRegistry(1, blocks, new Configuration());
ushort id = WorldGenerator.BlockAt(40, surfaceHeight: 70, biomes.Plains, blocks, fillerDepth: 3);
Assert.Equal(blocks.Stone.Id, id);
}