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.
35 lines
1.4 KiB
C#
35 lines
1.4 KiB
C#
using VoxelEngine.Core;
|
|
|
|
namespace VoxelEngine.World.WorldGen;
|
|
|
|
// Seeded wrapper over FastNoiseLite. All Get* methods return roughly [-1, 1].
|
|
public sealed class NoiseSource
|
|
{
|
|
private readonly FastNoiseLite _continent;
|
|
private readonly FastNoiseLite _temperature;
|
|
private readonly FastNoiseLite _forest;
|
|
|
|
public NoiseSource(int seed, Configuration cfg)
|
|
{
|
|
this._continent = new FastNoiseLite(seed);
|
|
this._continent.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
|
this._continent.SetFractalType(FastNoiseLite.FractalType.FBm);
|
|
this._continent.SetFractalOctaves(cfg.ContinentOctaves);
|
|
this._continent.SetFrequency(cfg.ContinentFrequency);
|
|
|
|
this._temperature = new FastNoiseLite(seed + 1);
|
|
this._temperature.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
|
this._temperature.SetFractalType(FastNoiseLite.FractalType.FBm);
|
|
this._temperature.SetFractalOctaves(cfg.TemperatureOctaves);
|
|
this._temperature.SetFrequency(cfg.TemperatureFrequency);
|
|
|
|
this._forest = new FastNoiseLite(seed + 2);
|
|
this._forest.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
|
this._forest.SetFrequency(cfg.ForestFrequency);
|
|
}
|
|
|
|
public float Continent(float x, float z) => this._continent.GetNoise(x, z);
|
|
public float Temperature(float x, float z) => this._temperature.GetNoise(x, z);
|
|
public float Forest(float x, float z) => this._forest.GetNoise(x, z);
|
|
}
|