|
@@ -8,11 +8,11 @@ namespace Render::Ground {
|
|
|
|
|
|
|
|
using std::uint32_t;
|
|
using std::uint32_t;
|
|
|
|
|
|
|
|
-namespace math_constants {
|
|
|
|
|
-inline constexpr float k_two_pi = ::Render::GL::math_constants::k_two_pi;
|
|
|
|
|
-} // namespace math_constants
|
|
|
|
|
|
|
+namespace MathConstants {
|
|
|
|
|
+inline constexpr float k_two_pi = ::Render::GL::MathConstants::k_two_pi;
|
|
|
|
|
+} // namespace MathConstants
|
|
|
|
|
|
|
|
-namespace hash_constants {
|
|
|
|
|
|
|
+namespace HashConstants {
|
|
|
inline constexpr uint32_t k_spatial_hash_prime_1 = 73856093U;
|
|
inline constexpr uint32_t k_spatial_hash_prime_1 = 73856093U;
|
|
|
inline constexpr uint32_t k_spatial_hash_prime_2 = 19349663U;
|
|
inline constexpr uint32_t k_spatial_hash_prime_2 = 19349663U;
|
|
|
inline constexpr uint32_t k_spatial_hash_prime_3 = 83492791U;
|
|
inline constexpr uint32_t k_spatial_hash_prime_3 = 83492791U;
|
|
@@ -29,17 +29,17 @@ inline constexpr float k_noise_frequency_x = 127.1F;
|
|
|
inline constexpr float k_noise_frequency_y = 311.7F;
|
|
inline constexpr float k_noise_frequency_y = 311.7F;
|
|
|
inline constexpr float k_noise_amplitude = 43758.5453123F;
|
|
inline constexpr float k_noise_amplitude = 43758.5453123F;
|
|
|
inline constexpr float k_temporal_variation_frequency = 37.0F;
|
|
inline constexpr float k_temporal_variation_frequency = 37.0F;
|
|
|
-} // namespace hash_constants
|
|
|
|
|
|
|
+} // namespace HashConstants
|
|
|
|
|
|
|
|
inline auto hash_coords(int x, int z, uint32_t salt = 0U) -> uint32_t {
|
|
inline auto hash_coords(int x, int z, uint32_t salt = 0U) -> uint32_t {
|
|
|
- auto const ux = static_cast<uint32_t>(x * hash_constants::k_spatial_hash_prime_1);
|
|
|
|
|
- auto const uz = static_cast<uint32_t>(z * hash_constants::k_spatial_hash_prime_2);
|
|
|
|
|
- return ux ^ uz ^ (salt * hash_constants::k_spatial_hash_prime_3);
|
|
|
|
|
|
|
+ auto const ux = static_cast<uint32_t>(x * HashConstants::k_spatial_hash_prime_1);
|
|
|
|
|
+ auto const uz = static_cast<uint32_t>(z * HashConstants::k_spatial_hash_prime_2);
|
|
|
|
|
+ return ux ^ uz ^ (salt * HashConstants::k_spatial_hash_prime_3);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
inline auto rand_01(uint32_t &state) -> float {
|
|
inline auto rand_01(uint32_t &state) -> float {
|
|
|
- state = state * hash_constants::k_linear_congruential_multiplier +
|
|
|
|
|
- hash_constants::k_linear_congruential_increment;
|
|
|
|
|
|
|
+ state = state * HashConstants::k_linear_congruential_multiplier +
|
|
|
|
|
+ HashConstants::k_linear_congruential_increment;
|
|
|
return static_cast<float>((state >> ::Render::GL::BitShift::Shift8) &
|
|
return static_cast<float>((state >> ::Render::GL::BitShift::Shift8) &
|
|
|
::Render::GL::BitShift::Mask24Bit) /
|
|
::Render::GL::BitShift::Mask24Bit) /
|
|
|
::Render::GL::BitShift::Mask24BitFloat;
|
|
::Render::GL::BitShift::Mask24BitFloat;
|
|
@@ -50,22 +50,22 @@ inline auto remap(float value, float min_out, float max_out) -> float {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
inline auto hash_to_01(uint32_t h) -> float {
|
|
inline auto hash_to_01(uint32_t h) -> float {
|
|
|
- h ^= h >> hash_constants::k_xor_shift_amount_17;
|
|
|
|
|
- h *= hash_constants::k_hash_mix_multiplier_1;
|
|
|
|
|
- h ^= h >> hash_constants::k_xor_shift_amount_11;
|
|
|
|
|
- h *= hash_constants::k_hash_mix_multiplier_2;
|
|
|
|
|
- h ^= h >> hash_constants::k_xor_shift_amount_15;
|
|
|
|
|
- h *= hash_constants::k_hash_mix_multiplier_3;
|
|
|
|
|
- h ^= h >> hash_constants::k_xor_shift_amount_14;
|
|
|
|
|
|
|
+ h ^= h >> HashConstants::k_xor_shift_amount_17;
|
|
|
|
|
+ h *= HashConstants::k_hash_mix_multiplier_1;
|
|
|
|
|
+ h ^= h >> HashConstants::k_xor_shift_amount_11;
|
|
|
|
|
+ h *= HashConstants::k_hash_mix_multiplier_2;
|
|
|
|
|
+ h ^= h >> HashConstants::k_xor_shift_amount_15;
|
|
|
|
|
+ h *= HashConstants::k_hash_mix_multiplier_3;
|
|
|
|
|
+ h ^= h >> HashConstants::k_xor_shift_amount_14;
|
|
|
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 noise_hash(float x, float y) -> float {
|
|
inline auto noise_hash(float x, float y) -> float {
|
|
|
- float const n = std::sin(x * hash_constants::k_noise_frequency_x +
|
|
|
|
|
- y * hash_constants::k_noise_frequency_y) *
|
|
|
|
|
- hash_constants::k_noise_amplitude;
|
|
|
|
|
|
|
+ float const n = std::sin(x * HashConstants::k_noise_frequency_x +
|
|
|
|
|
+ y * HashConstants::k_noise_frequency_y) *
|
|
|
|
|
+ HashConstants::k_noise_amplitude;
|
|
|
return n - std::floor(n);
|
|
return n - std::floor(n);
|
|
|
}
|
|
}
|
|
|
|
|
|