载入中...
搜索中...
未找到
CaveScallopHistory.cpp
浏览该文件的文档.
2
3#include <algorithm>
4#include <cmath>
5
6namespace eve::procgen {
7namespace {
8
9constexpr float Pi = 3.14159265358979323846f;
10
11float smoothstep(float lo, float hi, float value) {
12 const float t = std::clamp((value - lo) / std::max(hi - lo, 1e-6f), 0.f, 1.f);
13 return t * t * (3.f - 2.f * t);
14}
15
16} // namespace
17
20 const CaveScallopSample older = sampleCaveScallops(input.base);
21 result.erosion = older.erosion;
22 if (input.historyStrength <= 0.f) return result;
23
24 const float phase = float(input.base.seed % 997u) * (2.f * Pi / 997.f);
25 const float stageWindow = 0.5f + 0.34f * std::sin(input.base.along * 4.3f + phase) +
26 0.16f * std::sin(input.base.angle * 2.f - input.base.along * 1.7f + phase * 0.53f);
27 const float wallBand = 0.38f + 0.62f * smoothstep(-0.5f, 0.82f, std::sin(input.base.angle + phase * 0.11f));
28 result.youngerCoverage = input.historyStrength * wallBand * smoothstep(0.18f, 0.78f, stageWindow);
29
30 // Drainage capture and backflooding need not reverse an entire passage.
31 // A long-wave mask changes direction only in coherent reaches.
32 result.reversalMask = smoothstep(0.35f, 0.82f, 0.5f + 0.5f * std::sin(input.base.along * 2.6f - phase));
33 result.secondaryScaleRatio =
34 std::clamp(0.72f / std::sqrt(std::clamp(input.base.hydraulicIntensity, 0.35f, 1.45f)), 0.52f, 0.92f);
35
36 CaveScallopInput youngerInput = input.base;
37 youngerInput.baseScale *= result.secondaryScaleRatio;
38 youngerInput.along = input.base.along * (1.f - 2.f * result.reversalMask);
39 youngerInput.seed ^= 0x9e3779b9u;
40 const CaveScallopSample younger = sampleCaveScallops(youngerInput);
41 result.youngerErosion = younger.erosion * result.youngerCoverage;
42
43 // A younger stage can only remove more rock. Keeping its retreat bounded
44 // preserves readable remnants of the older population between stage windows.
45 result.erosion += result.youngerErosion * 0.36f;
46 return result;
47}
48
49} // namespace eve::procgen
double value
float phase
Definition CaveMesh.cpp:58
EvpackChunkInput input
Definition Evpack.cpp:170
float t
CaveScallopHistorySample sampleCaveScallopHistory(const CaveScallopHistoryInput &input)
Sample cumulative erosion from two spatially partitioned cave-flow stages.
CaveScallopSample sampleCaveScallops(const CaveScallopInput &input)
Sample cave scallops.
Inputs for a younger, spatially bounded cave-scallop erosion stage.
Observable combination of preserved older and younger scallop generations.
CaveScallopInput public API.
CaveScallopSample public API.