mapspinner 0.1.73 → 0.1.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapspinner",
3
- "version": "0.1.73",
3
+ "version": "0.1.74",
4
4
  "description": "WebGL2 Earth-scale terrain rendering SDK for interactive globe applications",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -760,6 +760,7 @@ out float vLakeWet; // lake open-water mask (carve basin)
760
760
  out float vRiverWet; // river thalweg wet line
761
761
  out float vWaterDepth; // metres the flat inland-water plane sits ABOVE the local terrain floor (>0 = submerged)
762
762
  out float vCanyonDep; // canyon gorge depth [0,1]
763
+ out float vConcavity; // height-field Laplacian / step^2 (1/m, +ve = concave valley/pit) -- ELEVATION AO signal (free from the normal central-diff taps)
763
764
  out float vCliffFace; // cliff/escarpment riser face [0,1] (1 = steep terrace face)
764
765
  out float vDuneCrest; // dune crest [0,1]
765
766
  out float vLevel; // quad LOD level (per-instance iOffset.w) for the patches debug view
@@ -1003,6 +1004,7 @@ void main() {
1003
1004
  // sides of a seam share the same dir0/tangent frame -> consistent normals, no row artifact.
1004
1005
  highp float hN0 = 0.0;
1005
1006
  highp vec3 vN = dir0;
1007
+ highp float concavRaw = 0.0; // height Laplacian / step^2 (+ve = concave) -- set in the land branches, free from the normal taps
1006
1008
  if (uIsWater < 0.5 && uThc > 0.5) {
1007
1009
  // THC FAST PATH: height + symmetric central-diff normal from the baked pool. 5 bilinear texture
1008
1010
  // taps replace 5 full composeHeight evals (the VS-bound cost). The 4 normal taps use the SAME
@@ -1058,6 +1060,23 @@ void main() {
1058
1060
  vN = normalize(cross(wPU - wMU, wPV - wMV));
1059
1061
  if (dot(vN, dir0) < 0.0) vN = -vN; // keep it outward (terrain has no overhangs)
1060
1062
  }
1063
+ // ELEVATION-AO CONCAVITY at LARGE scale (user 2026-06-14 'AO is focused on features too small, must
1064
+ // AO the larger features'): the 300m normal-step Laplacian keyed on small/sharp relief (canyons). Take
1065
+ // the Laplacian of broadShapeLowM (the cheap 8-oct LARGE-SCALE shape, no small carves) over a WIDE ~2km
1066
+ // step instead, so the AO darkens broad valleys/basins. broadShapeLowM is the same field the mesa
1067
+ // slope gate uses at a 1.2km step -> a known-cheap large-feature probe. Land only (water needs none).
1068
+ if (uIsWater < 0.5) {
1069
+ const highp float ecM = 2000.0; // wide finite-diff step = large-feature scale
1070
+ highp vec3 ux = normalize(cross(abs(dir0.y) < 0.99 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,0.0), dir0));
1071
+ highp vec3 uy = cross(dir0, ux);
1072
+ highp float h0c = broadShapeLowM(dir0);
1073
+ highp float hxp = broadShapeLowM(normalize(dir0 + ux * (ecM / defRadius)));
1074
+ highp float hxm = broadShapeLowM(normalize(dir0 - ux * (ecM / defRadius)));
1075
+ highp float hyp = broadShapeLowM(normalize(dir0 + uy * (ecM / defRadius)));
1076
+ highp float hym = broadShapeLowM(normalize(dir0 - uy * (ecM / defRadius)));
1077
+ concavRaw = (hxp + hxm + hyp + hym - 4.0 * h0c) / (ecM * ecM); // 1/m large-scale curvature, +ve = broad valley/basin
1078
+ }
1079
+ vConcavity = concavRaw;
1061
1080
  highp float h = hN0;
1062
1081
  // OCEAN TOP = A SEPARATE, ELEVATION-BASED SURFACE (user 2026-06-10: 'terrain should extend into
1063
1082
  // the ocean, the ocean top separate and elevation based'). composeHeight keeps carrying the TRUE
@@ -1135,6 +1154,7 @@ in float vLakeWet; // carve masks computed in the VS, interpolated (no per-pi
1135
1154
  in float vRiverWet;
1136
1155
  in float vWaterDepth; // metres of submerged water (>0 = real open inland water at the flat plane)
1137
1156
  in float vCanyonDep;
1157
+ in float vConcavity; // elevation-AO concavity (1/m, +ve = valley/pit)
1138
1158
  in float vCliffFace;
1139
1159
  in float vDuneCrest;
1140
1160
  in float vLevel; // quad LOD level (patches view)
@@ -1921,7 +1941,7 @@ void main() {
1921
1941
  // 3 normal octaves (user 2026-06-14 'add an even lower freq octave, displacement/normals only,
1922
1942
  // 4x less frequent'): wt4 high (detail) + wt low (2.4km) + wt*0.25 VERY-low (9.6km) -- the very-
1923
1943
  // low one breaks the far repetition even more. Normals/displacement only (no albedo).
1924
- vec3 nA = surfTriNrm(uSurfNrm, wt4, tw, lA, n) * 1.4 + surfTriNrm(uSurfNrm, wt, tw, lA, n) * 0.8 + surfTriNrm(uSurfNrm, wt * 0.25, tw, lA, n) * 2.4; // very-low octave UP 0.55->2.4 (user 2026-06-14 'dont really see the lower freq octave yet'): at a 9.6km period its slope is gentle, so it needs more weight to read as broad undulation
1944
+ vec3 nA = surfTriNrm(uSurfNrm, wt4, tw, lA, n) * 2.0 + surfTriNrm(uSurfNrm, wt, tw, lA, n) * 0.9 + surfTriNrm(uSurfNrm, wt * 0.25, tw, lA, n) * 1.1; // REBALANCED (user 2026-06-14 'higher octaves appear gone'): very-low 2.4 swamped the detail -> high (wt4) UP to 2.0 (dominant detail), very-low DOWN to 1.1 (still visible broad) (user 2026-06-14 'dont really see the lower freq octave yet'): at a 9.6km period its slope is gentle, so it needs more weight to read as broad undulation
1925
1945
  float dispA = albA.a;
1926
1946
  // NO BIOME COLOR INHERITANCE (user 2026-06-14 'take away all biome color inheritance, it will
1927
1947
  // speed it up' -- and fixes 'sand near grass tinted green'): each layer wears its OWN material
@@ -1933,7 +1953,7 @@ void main() {
1933
1953
  if (wB > 0.02) { // second layer only where a real transition exists
1934
1954
  vec4 albB = surfTriTap(uSurfAlb, wt4, tw, lB);
1935
1955
  vec3 cB = vec3(dot(albB.rgb, LUMA));
1936
- vec3 nB = surfTriNrm(uSurfNrm, wt4, tw, lB, n) * 1.4 + surfTriNrm(uSurfNrm, wt, tw, lB, n) * 0.8 + surfTriNrm(uSurfNrm, wt * 0.25, tw, lB, n) * 2.4; // very-low octave UP 0.55->2.4 (match nA)
1956
+ vec3 nB = surfTriNrm(uSurfNrm, wt4, tw, lB, n) * 2.0 + surfTriNrm(uSurfNrm, wt, tw, lB, n) * 0.9 + surfTriNrm(uSurfNrm, wt * 0.25, tw, lB, n) * 1.1; // REBALANCED (match nA)
1937
1957
  float dispB = albB.a;
1938
1958
  // HEIGHT-BLEND POKE-THROUGH (user 'each texture's higher areas should poke through the other,
1939
1959
  // offset by the ramp'): height = displacement + a weight-ramp offset (gate positions the
@@ -2031,13 +2051,16 @@ void main() {
2031
2051
  // crevices/pits read clearly. Still faded by k so the mipped far field is untouched.
2032
2052
  float texAO = mix(1.0, mix(0.5, 1.0, smoothstep(0.05, 0.6, texAlb.a)), k);
2033
2053
  albedo *= texAO;
2034
- // ELEVATION AO (user 2026-06-14 'similar AO on elevation'): the macro analog of the displacement
2035
- // AO -- darken CONCAVE relief (valley floors, gorges, recesses) using the screen-space CURVATURE
2036
- // of the lit normal. curv = d(normal).d(position) / |d(position)|^2 -> +ve where the surface
2037
- // curves into a pit (concave), -ve on ridges. Cheap (fwidth of the already-computed vNrm/vWorld).
2038
- highp vec3 ddxP = dFdx(vWorld), ddyP = dFdy(vWorld);
2039
- float curv = (dot(dFdx(vNrm), ddxP) + dot(dFdy(vNrm), ddyP)) / max(dot(ddxP, ddxP) + dot(ddyP, ddyP), 0.01);
2040
- float elevAO = 1.0 - clamp(curv * 420.0, 0.0, 0.65); // concave -> darken up to 65% (user 2026-06-14 x2 'elevation based ao not visible yet': macro relief curvature is small-magnitude, needs big gain 45->420)
2054
+ // ELEVATION AO (user 2026-06-14 x3 'similar AO on elevation / still not visible'): the screen-space
2055
+ // curvature of vNrm was ~0 (vNrm is a per-vertex analytic normal, linearly interpolated -> its
2056
+ // fwidth is tiny on the coarse grid = invisible). Replaced with vConcavity = the height-field
2057
+ // LAPLACIAN computed FREE from the VS normal central-diff taps (1/m, +ve = concave valley/pit),
2058
+ // a real object-space relief signal that survives interpolation. Darken concavities up to 65%.
2059
+ // VERY GRADUAL response (user 2026-06-14 'ao works but not gradiated, must be very gradual'): the
2060
+ // hard clamp(.,0.6) flat-topped every valley past a threshold = a visible AO edge + no gradation
2061
+ // between medium and deep concavity. Exponential SOFT saturation instead -- monotonic, smooth
2062
+ // onset AND smooth approach to the 0.6 floor, so darkening grades continuously with depth, no edge.
2063
+ float elevAO = 1.0 - 0.6 * (1.0 - exp(-max(vConcavity, 0.0) * 2500.0)); // concavRaw ~=1/Rc of the LARGE shape (~3-7e-4 for km-scale basins): broad valley eases in, asymptotes to -60%
2041
2064
  albedo *= elevAO;
2042
2065
  // displacement-normal relief: WORLD-SPACE UDN perturbation from surfTriNrm (each projection
2043
2066
  // plane's tangent axes, not the radial frame). Amplitude capped low (scramble lesson d262b5e);