generate terrain height as Rivers' GenTerra does

98.2% of stored columns match exactly; the rest is the dry seabed
raise and surface caves, both later passes that the strata never see.
GenTerra thresholds the new terrain noise through the old tanh curve's
inverse, and matching that quirk is what moved it from 87%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 19:10:54 +03:00
parent 517d279c8d
commit c4c7ab9968
10 changed files with 1248 additions and 33 deletions

View File

@@ -15,6 +15,7 @@
(define SQUISH-3D 0.3333333333333333)
(define NORM-2D 0.02127659574468085)
(define NORM-3D 0.009708737864077669)
(define NORM-2D-WARP 0.020435461373899677)
(pub define MAX-VALUE-3D 0.9871465422297019)
(define VALUE-MULTIPLIER 1.2)
(pub define MAX-OCTAVES 16)
@@ -333,3 +334,128 @@
(var v double (* (.eval-2d (& [(. self octaves) i]) (* x f) (* y f)) [(. self amplitudes) i]))
(+= value (if (> v 0.0) (fmax 0.0 (- v [thresholds i])) (fmin 0.0 (+ v [thresholds i])))))
(return value)))
;;; Generated from vsapi SimplexOctave.cs warpUpgradeVectors2D; do not edit.
(var warp-vectors [double 384]
#(0.9238795325112866 0.3826834323650898 4.97524354451166 2.060813352245919 -4.975243544511659 -2.060813352245919
0.7071067811865476 0.7071067811865476 3.807886552931954 3.807886552931954 3.8078865529319543 -3.8078865529319543
1.0 0.0 4.975243544511659 2.0608133522459187 4.975243544511659 -2.0608133522459187
0.3826834323650897 0.9238795325112867 0.0 5.385164807134505 5.385164807134505 0.0
1.0 0.0 4.975243544511659 2.0608133522459187 -4.975243544511659 2.0608133522459187
0.9238795325112867 -0.3826834323650897 3.807886552931954 3.807886552931954 -3.807886552931954 3.807886552931954
0.9238795325112866 0.3826834323650898 4.975243544511659 2.060813352245919 4.97524354451166 2.060813352245919
0.7071067811865476 0.7071067811865476 3.8078865529319543 -3.8078865529319543 3.807886552931954 3.807886552931954
0.7071067811865476 0.7071067811865476 3.807886552931954 3.807886552931954 -3.8078865529319543 3.8078865529319543
0.3826834323650898 0.9238795325112866 2.060813352245919 4.97524354451166 2.060813352245919 4.975243544511659
-0.3826834323650897 0.9238795325112867 -5.385164807134505 0.0 0.0 5.385164807134505
0.0 1.0 -2.0608133522459187 4.975243544511659 2.0608133522459187 4.975243544511659
0.9238795325112867 0.3826834323650897 3.807886552931954 3.807886552931954 -3.807886552931954 3.807886552931954
0.0 1 2.0608133522459187 -4.975243544511659 2.0608133522459187 4.975243544511659
0.7071067811865476 0.7071067811865476 -3.8078865529319543 3.8078865529319543 3.807886552931954 3.807886552931954
0.3826834323650898 0.9238795325112866 -2.060813352245919 -4.975243544511659 2.060813352245919 4.97524354451166
-1.0 0.0 4.975243544511659 -2.0608133522459187 4.975243544511659 2.0608133522459187
-0.3826834323650897 0.9238795325112867 3.807886552931954 3.807886552931954 -3.807886552931954 3.807886552931954
-0.9238795325112866 0.3826834323650898 4.975243544511659 -2.060813352245919 -4.97524354451166 2.060813352245919
-0.7071067811865476 0.7071067811865476 3.8078865529319543 3.8078865529319543 -3.807886552931954 3.807886552931954
-0.9238795325112866 0.3826834323650898 4.97524354451166 -2.060813352245919 4.975243544511659 -2.060813352245919
-0.7071067811865476 0.7071067811865476 3.807886552931954 -3.807886552931954 -3.8078865529319543 -3.8078865529319543
-1.0 0.0 4.975243544511659 -2.0608133522459187 -4.975243544511659 -2.0608133522459187
-0.9238795325112867 -0.3826834323650897 5.385164807134505 0.0 0.0 -5.385164807134505
0.3826834323650897 0.9238795325112867 3.807886552931954 3.807886552931954 -3.807886552931954 3.807886552931954
0.0 1.0 2.0608133522459187 4.975243544511659 -2.0608133522459187 4.975243544511659
-0.7071067811865476 0.7071067811865476 -3.8078865529319543 -3.8078865529319543 -3.807886552931954 3.807886552931954
-0.3826834323650898 0.9238795325112866 -2.060813352245919 4.975243544511659 -2.060813352245919 4.97524354451166
-0.7071067811865476 0.7071067811865476 3.807886552931954 -3.807886552931954 3.8078865529319543 3.8078865529319543
-0.3826834323650898 0.9238795325112866 2.060813352245919 -4.97524354451166 -2.060813352245919 4.975243544511659
-0.9238795325112867 0.3826834323650897 0.0 -5.385164807134505 -5.385164807134505 0.0
0.0 1.0 -2.0608133522459187 -4.975243544511659 -2.0608133522459187 4.975243544511659
1.0 0.0 4.975243544511659 -2.0608133522459187 -4.975243544511659 -2.0608133522459187
0.9238795325112867 0.3826834323650897 5.385164807134505 0.0 0.0 -5.385164807134505
0.9238795325112866 -0.3826834323650898 4.97524354451166 -2.060813352245919 4.975243544511659 -2.060813352245919
0.7071067811865476 -0.7071067811865476 3.807886552931954 -3.807886552931954 -3.8078865529319543 -3.8078865529319543
0.9238795325112866 -0.3826834323650898 4.975243544511659 -2.060813352245919 -4.97524354451166 2.060813352245919
0.7071067811865476 -0.7071067811865476 3.8078865529319543 3.8078865529319543 -3.807886552931954 3.807886552931954
1.0 0.0 4.975243544511659 -2.0608133522459187 4.975243544511659 2.0608133522459187
0.3826834323650897 -0.9238795325112867 3.807886552931954 3.807886552931954 -3.807886552931954 3.807886552931954
0.9238795325112867 -0.3826834323650897 0.0 -5.385164807134505 -5.385164807134505 0.0
0.0 -1.0 -2.0608133522459187 -4.975243544511659 -2.0608133522459187 4.975243544511659
0.7071067811865476 -0.7071067811865476 3.807886552931954 -3.807886552931954 3.8078865529319543 3.8078865529319543
0.3826834323650898 -0.9238795325112866 2.060813352245919 -4.97524354451166 -2.060813352245919 4.975243544511659
0.7071067811865476 -0.7071067811865476 -3.8078865529319543 -3.8078865529319543 -3.807886552931954 3.807886552931954
0.3826834323650898 -0.9238795325112866 -2.060813352245919 4.975243544511659 -2.060813352245919 4.97524354451166
-0.3826834323650897 -0.9238795325112867 3.807886552931954 3.807886552931954 -3.807886552931954 3.807886552931954
0.0 -1.0 2.0608133522459187 4.975243544511659 -2.0608133522459187 4.975243544511659
-0.9238795325112866 -0.3826834323650898 4.975243544511659 2.060813352245919 4.97524354451166 2.060813352245919
-0.7071067811865476 -0.7071067811865476 3.8078865529319543 -3.8078865529319543 3.807886552931954 3.807886552931954
-1.0 0.0 4.975243544511659 2.0608133522459187 -4.975243544511659 2.0608133522459187
-0.9238795325112867 0.3826834323650897 3.807886552931954 3.807886552931954 -3.807886552931954 3.807886552931954
-1.0 0.0 4.975243544511659 2.0608133522459187 4.975243544511659 -2.0608133522459187
-0.3826834323650897 -0.9238795325112867 0.0 5.385164807134505 5.385164807134505 0.0
-0.9238795325112866 -0.3826834323650898 4.97524354451166 2.060813352245919 -4.975243544511659 -2.060813352245919
-0.7071067811865476 -0.7071067811865476 3.807886552931954 3.807886552931954 3.8078865529319543 -3.8078865529319543
-0.7071067811865476 -0.7071067811865476 -3.8078865529319543 3.8078865529319543 3.807886552931954 3.807886552931954
-0.3826834323650898 -0.9238795325112866 -2.060813352245919 -4.975243544511659 2.060813352245919 4.97524354451166
-0.9238795325112867 -0.3826834323650897 3.807886552931954 3.807886552931954 -3.807886552931954 3.807886552931954
0.0 -1.0 2.0608133522459187 -4.975243544511659 2.0608133522459187 4.975243544511659
0.3826834323650897 -0.9238795325112867 -5.385164807134505 0.0 0.0 5.385164807134505
0.0 -1.0 -2.0608133522459187 4.975243544511659 2.0608133522459187 4.975243544511659
-0.7071067811865476 -0.7071067811865476 3.807886552931954 3.807886552931954 -3.8078865529319543 3.8078865529319543
-0.3826834323650898 -0.9238795325112866 2.060813352245919 4.97524354451166 2.060813352245919 4.975243544511659))
;;; SimplexNoiseOctave.EvaluateFairWarpVector: a 2D warp from a pair of
;;; octaves, rotated so its directions are fairer than two independent
;;; noises'.
(fn fair-warp-octave ((ox (* const simplex-octave)) (oz (* const simplex-octave))
(x double) (y double) (out-x (* double)) (out-y (* double))) void
(var stretch double (* (+ x y) STRETCH-2D))
(var xs double (+ x stretch))
(var ys double (+ y stretch))
(var xsb int (cast (floor xs) int))
(var ysb int (cast (floor ys) int))
(-= xs xsb)
(-= ys ysb)
(var squish double (* (+ xsb ysb) SQUISH-2D))
(var dx0 double (- x (+ xsb squish)))
(var dy0 double (- y (+ ysb squish)))
(var in-sum double (+ xs ys))
(var hash u32 (c-bit-or (cast (+ (- xs ys) 1) u32)
(<< (cast in-sum u32) 1)
(<< (cast (+ in-sum ys) u32) 2)
(<< (cast (+ in-sum xs) u32) 4)))
(var dist-x double 0)
(var dist-y double 0)
(for (var c int [lookup-2d hash]) (>= c 0) (= c (. [pool c] next))
(var dx double (+ dx0 (. [pool c] dx)))
(var dy double (+ dy0 (. [pool c] dy)))
(var attn double (- 2.0 (* dx dx) (* dy dy)))
(if (> attn 0.0)
(do
(var px int (+ xsb (. [pool c] xsb)))
(var py int (+ ysb (. [pool c] ysb)))
(var i int [(. ox perm-2d) (& (+ [(. ox perm) (& px 255)] py) 255)])
(var j int [(. oz perm-2d) (& (+ [(. oz perm) (& px 255)] py) 255)])
(var k int (* (+ (* i 8) j) 3))
(var rx double [warp-vectors k])
(var ry double [warp-vectors (+ k 1)])
(var a double (+ (* [warp-vectors (+ k 2)] dx) (* [warp-vectors (+ k 3)] dy)))
(var b double (+ (* [warp-vectors (+ k 4)] dx) (* [warp-vectors (+ k 5)] dy)))
(*= attn attn)
(*= attn attn)
(+= dist-x (* attn (+ (* a rx) (* b ry))))
(+= dist-y (* attn (- (* a ry) (* b rx)))))))
(= (* out-x) (* dist-x NORM-2D-WARP))
(= (* out-y) (* dist-y NORM-2D-WARP)))
;;; SimplexNoise.NoiseFairWarpVector over the octaves of two noises
;;; made alike.
(pub fn fair-warp ((nx (* const simplex-sum)) (nz (* const simplex-sum)) (x double) (y double)
(out-x (* double)) (out-y (* double))) void
(= (* out-x) 0)
(= (* out-y) 0)
(for (var i int 0) (< i (. nx count)) (++ i)
(var f double [(. nx frequencies) i])
(var hx double)
(var hy double)
(fair-warp-octave (& [(. nx octaves) i]) (& [(. nz octaves) i]) (* x f) (* y f) (& hx) (& hy))
(+= (* out-x) (* hx [(. nx amplitudes) i]))
(+= (* out-y) (* hy [(. nx amplitudes) i]))))