feat: add seeded NoiseSource over FastNoiseLite

This commit is contained in:
MDietermann
2026-05-31 21:46:53 +02:00
parent 99b411bdbd
commit 44f53e8d50
2 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
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)
{
this._continent = new FastNoiseLite(seed);
this._continent.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
this._continent.SetFractalType(FastNoiseLite.FractalType.FBm);
this._continent.SetFractalOctaves(4);
this._continent.SetFrequency(0.0035f);
this._temperature = new FastNoiseLite(seed + 1);
this._temperature.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
this._temperature.SetFractalType(FastNoiseLite.FractalType.FBm);
this._temperature.SetFractalOctaves(3);
this._temperature.SetFrequency(0.0015f);
this._forest = new FastNoiseLite(seed + 2);
this._forest.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
this._forest.SetFrequency(0.02f);
}
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);
}