载入中...
搜索中...
未找到
CaveAbrasion.cpp
浏览该文件的文档.
2
3#include <algorithm>
4#include <cmath>
5
6namespace eve::procgen {
7namespace {
8
9float smoothstep(float lo, float hi, float value) {
10 const float t = std::clamp((value - lo) / std::max(hi - lo, 1e-6f), 0.f, 1.f);
11 return t * t * (3.f - 2.f * t);
12}
13
14} // namespace
15
17 CaveAbrasionSample result;
18 if (input.sedimentLoad <= 0.f) return result;
19
20 // angle is zero at the crown and pi at the floor. Suspended impacts and
21 // saltating grains rapidly lose erosive power above the near-bed zone.
22 result.floorMask = std::pow(std::max(0.f, -std::cos(input.angle)), 1.65f);
23 result.toolAvailability = smoothstep(0.025f, 0.28f, input.sedimentLoad);
24 result.coverProtection = std::clamp(input.sedimentLoad * input.sedimentLoad * 0.68f, 0.f, 0.68f);
25 const float toolsAndCover = result.toolAvailability * (1.f - result.coverProtection);
26
27 const float seedPhase = float(input.seed % 2039u) * 0.003081503f;
28 // Low-frequency coherent cells represent persistent recirculation and
29 // impact patches. They are enhanced at bends but remain present in straight floods.
30 const float cell = 0.5f + 0.5f * std::sin(input.along * 12.5f + seedPhase +
31 std::sin(input.along * 3.1f + seedPhase * 1.7f) * 1.15f);
32 const float lateralCell = 0.5f + 0.5f * std::cos((input.angle - 3.1415926535f) * 3.2f +
33 std::sin(input.along * 5.3f + seedPhase * 0.7f) * 0.8f);
34 const float bendSide = std::max(0.f, std::cos(input.angle - input.outerBankAngle));
35 result.vortexMask = std::clamp(cell * lateralCell * (0.55f + input.bendStrength * bendSide * 0.75f), 0.f, 1.f);
36 const float fluting =
37 0.35f + 0.65f * smoothstep(-0.45f, 0.65f, std::sin(input.along * 25.f + input.angle * 2.f + seedPhase * 2.3f));
38 const float streamPower = std::pow(std::clamp(input.hydraulicIntensity, 0.f, 1.7f), 1.25f);
39 result.erosion = std::clamp(
40 result.floorMask * toolsAndCover * streamPower * (0.38f + 0.62f * result.vortexMask) * fluting, 0.f, 1.f);
41 return result;
42}
43
44} // namespace eve::procgen
double value
EvpackChunkInput input
Definition Evpack.cpp:170
float t
Cell cell
CaveAbrasionSample sampleCaveFloodAbrasion(const CaveAbrasionInput &input)
Sample mechanical erosion by sediment-laden floods near the passage bed.
Inputs for sediment-laden flood abrasion of a cave passage.
Near-bed abrasion, sediment cover, and coherent vortex-cell response.