载入中...
搜索中...
未找到
CaveFractures.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
19 const float planeDistance =
20 std::fabs(input.x * input.fracture.normalX + input.z * input.fracture.normalZ - input.fracture.offset);
21 const float tangent = -input.fracture.normalZ * input.x + input.fracture.normalX * input.z;
22 const float seedPhase = float(input.seed % 1009u) * (2.f * Pi / 1009.f);
23
24 // Natural fracture apertures are correlated patches, not independent voxel noise.
25 const float apertureField = 0.62f * std::sin(tangent * 7.2f + input.y * 2.1f + seedPhase) +
26 0.38f * std::sin(tangent * 3.1f - input.y * 5.4f - seedPhase * 0.73f);
27 const float apertureMultiplier = std::exp(input.apertureVariability * 0.55f * apertureField);
28 const float aperture = input.fracture.aperture * apertureMultiplier;
29 const float planeMask = 1.f - smoothstep(aperture, aperture * 5.f, planeDistance);
30
31 // Jiang et al. (2025) observed stress-split dissolution fronts and persistent branches.
32 // Two travelling centres divide, curve, and reconnect along the fracture plane.
33 const float progression = input.y * 4.1f + seedPhase;
34 const float split =
35 (0.055f + 0.035f * std::sin(progression * 0.47f)) * smoothstep(-0.35f, 0.30f, std::sin(progression));
36 const float drift = 0.11f * std::sin(input.y * 2.6f + seedPhase * 1.37f);
37 const float branchWidth = 0.055f + 0.018f * (0.5f + 0.5f * std::sin(progression * 1.31f));
38 const float branchA = 1.f - smoothstep(branchWidth, branchWidth * 2.8f, std::fabs(tangent - drift - split));
39 const float branchB = 1.f - smoothstep(branchWidth, branchWidth * 2.8f, std::fabs(tangent - drift + split));
40 const float branchCore = std::max(branchA, branchB);
41 const float branchOpenness = (1.f - input.stressControl) + input.stressControl * (0.18f + 0.82f * branchCore);
42
43 return {planeMask * branchOpenness, apertureMultiplier, branchOpenness};
44}
45
46} // namespace eve::procgen
double value
Vec3 tangent
Definition CaveMesh.cpp:80
bool split
Definition CaveMesh.cpp:123
EvpackChunkInput input
Definition Evpack.cpp:170
float t
CaveFractureSample sampleCaveFracture(const CaveFractureInput &input)
Sample a spatially correlated fracture aperture and stress-split dissolution front.
Inputs for heterogeneous, stress-controlled fracture dissolution.
Observable local state of a sampled dissolving fracture.