Generator Refactor
This commit is contained in:
@@ -15,6 +15,7 @@ namespace CaveGame::Core
|
||||
{
|
||||
public:
|
||||
static constexpr int PrecomputedWhiteNoiseResolution = 2048;
|
||||
|
||||
static constexpr float BaseSurfaceLvl = 100.f;
|
||||
static constexpr float HeightMapHighPassAmplitude = 700.f;
|
||||
static constexpr float HeightMapHighPassScale = 700.f;
|
||||
@@ -34,8 +35,7 @@ namespace CaveGame::Core
|
||||
static constexpr float ClayVeinHiPassOffset = 0.f;
|
||||
static constexpr float ClayVeinHiPassOutputScale = 2.2f;
|
||||
|
||||
static constexpr float ClayVeinLoPassHScale = 17.f;
|
||||
static constexpr float ClayVeinLoPassVScale = 15.f;
|
||||
static constexpr Vector2 ClayVeinLoPassScale = {17.f, 15.f};
|
||||
static constexpr float ClayVeinLoPassOffset = 420.f;
|
||||
static constexpr float ClayVeinLoPassOutputScale = 1.2f;
|
||||
|
||||
|
@@ -17,6 +17,8 @@ namespace CaveGame::Core
|
||||
{
|
||||
precomputed_white_noise_2D[x][y] = rng.Float01Incl();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +55,11 @@ namespace CaveGame::Core
|
||||
return perlin.Noise(wx / hScale, wy / vScale, offset) * outputScale;
|
||||
}
|
||||
|
||||
float Generator::Perlin2(int wx, int wy, const Vector2 hiScale, const Vector2 loScale, Vector2 offset, Vector2 outputScale)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float Generator::Octave(int wx, int wy, float hScale, float vScale, float offset, float outputScale, int octaves) {
|
||||
|
||||
float noise = 0;
|
||||
@@ -86,7 +93,7 @@ namespace CaveGame::Core
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Calculates the tile to be placed at a given x,y coordinates during the first terrain iteration.
|
||||
TileID Generator::ComputeTile(int wx, int wy) {
|
||||
float depth = ComputeDepth(wx, wy);
|
||||
TileID base = HeightMap(depth, wx, wy);
|
||||
@@ -130,23 +137,12 @@ namespace CaveGame::Core
|
||||
|
||||
if (depth > 1) {
|
||||
// Ore computation
|
||||
//float clay_pass_1 = perlin.Noise(wx / ClayVeinHiPassHScale, wy / ClayVeinHiPassVScale, ClayVeinHiPassOffset) * ClayVeinHiPassOutputScale;
|
||||
|
||||
float clay_pass_1 = Perlin(wx, wy, ClayVeinHiPassHScale, ClayVeinHiPassVScale, ClayVeinHiPassOffset, ClayVeinHiPassOutputScale);
|
||||
|
||||
//float clay_pass_2 = perlin.Noise(wx / ClayVeinLoPassHScale, wy / ClayVeinLoPassVScale, ClayVeinLoPassOffset) * ClayVeinLoPassOutputScale;
|
||||
|
||||
float clay_pass_2 = Perlin(wx, wy, ClayVeinLoPassHScale, ClayVeinLoPassVScale, ClayVeinLoPassOffset, ClayVeinLoPassOutputScale);
|
||||
|
||||
float rng = GetPrecomputedWhiteNoise2D(wx, wy)*0.175;
|
||||
|
||||
//float clay_pass = clay_pass_1 + clay_pass_2 + ((clay_pass_1 * clay_pass_2) / 2.f) - rng;
|
||||
|
||||
float clay_pass = ComputeHiLoPass(clay_pass_1, clay_pass_2, 2.f) - rng;
|
||||
|
||||
float clay_pass_1 = Perlin(wx, wy, ClayVeinHiPassScale.x, ClayVeinHiPassScale.y, ClayVeinHiPassOffset, ClayVeinHiPassOutputScale);
|
||||
float clay_pass_2 = Perlin(wx, wy, ClayVeinLoPassScale.x, ClayVeinLoPassScale.y, ClayVeinLoPassOffset, ClayVeinLoPassOutputScale);
|
||||
float clay_rng = GetPrecomputedWhiteNoise2D(wx, wy)*ClayVeinNoise;
|
||||
float clay_pass = ComputeHiLoPass(clay_pass_1, clay_pass_2, ClayVeinRampFactor) - clay_rng;
|
||||
|
||||
if (clay_pass > 0.85f) { return TileID::CLAY; }
|
||||
|
||||
if (clay_pass < -0.75f) { return TileID::DIRT; }
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user