载入中...
搜索中...
未找到
CaveBiogenicCorrosion.cpp
浏览该文件的文档.
2
3#include <algorithm>
4#include <cmath>
5
6namespace eve::procgen {
7namespace {
8
9constexpr float Pi = 3.1415926535f;
10
11float smoothstep(float low, float high, float value) {
12 const float t = std::clamp((value - low) / (high - low), 0.f, 1.f);
13 return t * t * (3.f - 2.f * t);
14}
15
16float seedPhase(uint32_t seed, uint32_t salt) {
17 uint32_t value = seed ^ salt;
18 value ^= value >> 16u;
19 value *= 0x7feb352du;
20 value ^= value >> 15u;
21 return float(value & 0xffffu) * (2.f * Pi / 65536.f);
22}
23
24} // namespace
25
28 if (input.strength <= 0.f) return result;
29
30 const float strength = std::clamp(input.strength, 0.f, 1.f);
31 const float wallMask = 1.f - smoothstep(input.radius * 1.1f, input.radius * 2.1f, input.distance);
32 // Fast water films remove ammonia and wall microbial communities. Slow or absent
33 // films permit the subaerial overprint to erase older fluvial signatures.
34 const float filmProtection = smoothstep(0.95f, 1.45f, input.hydraulicExposure);
35 const float exposure = wallMask * (1.f - 0.82f * filmProtection);
36 result.fluvialScallopRetention = 1.f - strength * exposure * 0.86f;
37
38 const float largeScale = std::max(0.22f, input.radius * 2.8f);
39 const float phaseA = seedPhase(input.seed, 0x81f3a62du);
40 const float phaseB = seedPhase(input.seed, 0x43b7d159u);
41 const float alongWave = 0.5f + 0.5f * std::cos(input.along * 2.f * Pi / largeScale + phaseA);
42 const float broadLobe = 0.5f + 0.5f * std::cos(input.angle * 3.f + phaseB + 0.25f * std::sin(input.along * 3.f));
43 const float megascallop = std::pow(std::clamp(alongWave * broadLobe, 0.f, 1.f), 0.58f);
44
45 // Long angular bands change only slowly along the passage, producing flutes
46 // aligned with air transport instead of isotropic surface noise.
47 const float fluteWave = std::max(0.f, std::cos(input.angle * 7.f + phaseA + 0.14f * std::sin(input.along * 5.f)));
48 const float fluting = std::pow(fluteWave, 1.7f);
49 const float sponge = std::max(0.f, std::sin(input.along * 11.f + phaseB) * std::cos(input.angle * 5.f - phaseA));
50 result.erosion = strength * exposure * (0.56f * megascallop + 0.29f * fluting + 0.15f * sponge);
51 return result;
52}
53
54} // namespace eve::procgen
double value
EvpackChunkInput input
Definition Evpack.cpp:170
std::uint32_t seed
Definition PointSet.cpp:807
float t
CaveBiogenicCorrosionSample sampleCaveBiogenicCorrosion(const CaveBiogenicCorrosionInput &input)
Sample an airflow-aligned, guano-ammonia biogenic corrosion overprint.
CaveBiogenicCorrosionInput public API.
CaveBiogenicCorrosionSample public API.