|
@@ -1,6 +1,7 @@
|
|
|
#pragma once
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../gl/render_constants.h"
|
|
#include "../gl/render_constants.h"
|
|
|
|
|
+#include <cmath>
|
|
|
#include <cstdint>
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
namespace Render::Ground {
|
|
namespace Render::Ground {
|
|
@@ -15,7 +16,15 @@ inline constexpr uint32_t LcgMultiplier = 1664525U;
|
|
|
inline constexpr uint32_t LcgIncrement = 1013904223U;
|
|
inline constexpr uint32_t LcgIncrement = 1013904223U;
|
|
|
inline constexpr uint32_t XorShift17 = 17;
|
|
inline constexpr uint32_t XorShift17 = 17;
|
|
|
inline constexpr uint32_t XorShift11 = 11;
|
|
inline constexpr uint32_t XorShift11 = 11;
|
|
|
-inline constexpr uint32_t MixConstant = 0xed5ad4bbU;
|
|
|
|
|
|
|
+inline constexpr uint32_t XorShift15 = 15;
|
|
|
|
|
+inline constexpr uint32_t XorShift14 = 14;
|
|
|
|
|
+inline constexpr uint32_t MixConstant1 = 0xed5ad4bbU;
|
|
|
|
|
+inline constexpr uint32_t MixConstant2 = 0xac4c1b51U;
|
|
|
|
|
+inline constexpr uint32_t MixConstant3 = 0x31848babU;
|
|
|
|
|
+inline constexpr float NoiseHashX = 127.1F;
|
|
|
|
|
+inline constexpr float NoiseHashY = 311.7F;
|
|
|
|
|
+inline constexpr float NoiseHashScale = 43758.5453123F;
|
|
|
|
|
+inline constexpr float TemporalHashFrequency = 37.0F;
|
|
|
} // namespace HashConstants
|
|
} // namespace HashConstants
|
|
|
|
|
|
|
|
inline auto hashCoords(int x, int z, uint32_t salt = 0U) -> uint32_t {
|
|
inline auto hashCoords(int x, int z, uint32_t salt = 0U) -> uint32_t {
|
|
@@ -37,13 +46,22 @@ inline auto remap(float value, float minOut, float maxOut) -> float {
|
|
|
|
|
|
|
|
inline auto hashTo01(uint32_t h) -> float {
|
|
inline auto hashTo01(uint32_t h) -> float {
|
|
|
h ^= h >> HashConstants::XorShift17;
|
|
h ^= h >> HashConstants::XorShift17;
|
|
|
- h *= HashConstants::MixConstant;
|
|
|
|
|
|
|
+ h *= HashConstants::MixConstant1;
|
|
|
h ^= h >> HashConstants::XorShift11;
|
|
h ^= h >> HashConstants::XorShift11;
|
|
|
- h *= HashConstants::MixConstant;
|
|
|
|
|
- h ^= h >> HashConstants::XorShift17;
|
|
|
|
|
|
|
+ h *= HashConstants::MixConstant2;
|
|
|
|
|
+ h ^= h >> HashConstants::XorShift15;
|
|
|
|
|
+ h *= HashConstants::MixConstant3;
|
|
|
|
|
+ h ^= h >> HashConstants::XorShift14;
|
|
|
return static_cast<float>((h >> ::Render::GL::BitShift::Shift8) &
|
|
return static_cast<float>((h >> ::Render::GL::BitShift::Shift8) &
|
|
|
::Render::GL::BitShift::Mask24Bit) /
|
|
::Render::GL::BitShift::Mask24Bit) /
|
|
|
::Render::GL::BitShift::Mask24BitFloat;
|
|
::Render::GL::BitShift::Mask24BitFloat;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+inline auto noiseHash(float x, float y) -> float {
|
|
|
|
|
+ float const n = std::sin(x * HashConstants::NoiseHashX +
|
|
|
|
|
+ y * HashConstants::NoiseHashY) *
|
|
|
|
|
+ HashConstants::NoiseHashScale;
|
|
|
|
|
+ return n - std::floor(n);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
} // namespace Render::Ground
|
|
} // namespace Render::Ground
|