mapspinner 0.1.36 → 0.1.38

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.36",
3
+ "version": "0.1.38",
4
4
  "description": "WebGL2 Earth-scale terrain rendering SDK for interactive globe applications",
5
5
  "main": "src/index.js",
6
6
  "exports": {
package/src/gl-render.js CHANGED
@@ -49,7 +49,7 @@ export async function initMapspinnerRender(gl, opts = {}) {
49
49
  // (-52%) and tris/quad 1152->512 (-55%), so the per-vertex 14-oct broadShapeM VS (browser-9: 95% of
50
50
  // the low-alt frame) runs on ~half the vertices. median scales ~24/16 -> ~3.6px, far closer to the
51
51
  // band; the fine relief is carried per-pixel by the FS dFdx normal, not the mesh tessellation.
52
- const GRID = opts.gridMeshSize || 8; // mesh quads per edge. FPS is TRIANGLE/VERTEX-throughput bound (not ALU). 16->11->8 (user 2026-06-14 144fps push): GRID 8 reclaimed once the biome bands were WARPED (warpN, no longer straight contours) and the relief-faceting (dFdx(vH)) was removed, so the earlier GRID-8 jaggedness is gone. Override via ?grid=N.
52
+ const GRID = opts.gridMeshSize || 11; // mesh quads per edge. 16->11 (user 2026-06-14): FPS is TRIANGLE-THROUGHPUT bound, not broadShapeM ALU (octMax 12->3 left frame time flat; GRID is ~linear). GRID 8 was faster (-50%) but made BIOME CROSSOVER LINES JAGGED (climate varying interpolated across coarse triangles steps along edges) -- reverted to 11 (-37%). Proper fix to reclaim GRID 8 = per-pixel biome sampling in the FS. Override via ?grid=N.
53
53
  // Expose the LIVE mesh grid so screen-space-error diagnostics (planet.html __diag.pxPerPoly)
54
54
  // divide by the real polys/tile instead of a stale literal. Any future GRID change self-corrects
55
55
  // the metric (the 24->16 lever left pxPerPoly defaulting to 24 = 1.5x wrong band fraction).
@@ -286,6 +286,7 @@ export async function initMapspinnerRender(gl, opts = {}) {
286
286
  gl.uniform1f(loc('uDetailOverlay'), g('detailOverlay', 6.0)); // perlin-everywhere ELEVATION term in composeHeight -- probe must match the VS or collision diverges
287
287
  gl.uniform1f(loc('vtxDetail'), g('vtxDetail', 1.0)); // DECISIVE: vtxDisplace strength (early-return on 0)
288
288
  gl.uniform1f(loc('canyonDepthMul'), g('canyonDepth', 1.0));
289
+ gl.uniform1f(loc('uVsCheap'), (typeof window!=='undefined' && window.__vsCheap) ? 1.0 : 0.0); // VS carve-cost profiling A/B
289
290
  gl.uniform1f(loc('uBeachShelfM'), g('beachShelf', 2400.0)); // land coastal shelf (geometry); probe MUST match render
290
291
  gl.uniform1f(loc('cliffAmt'), g('cliffAmt', 1.0));
291
292
  gl.uniform1i(loc('uFloatLinearOK'), _halfFloatLinearOK ? 1 : 0);
@@ -806,6 +807,7 @@ export async function initMapspinnerRender(gl, opts = {}) {
806
807
  // literals so the look is unchanged until the user dials a window global.
807
808
  const _g = (n,d)=> (typeof window!=='undefined' && window['__'+n]!=null) ? +window['__'+n] : d;
808
809
  gl.uniform1f(U('canyonDepthMul'), _g('canyonDepth', 1.0));
810
+ gl.uniform1f(U('uVsCheap'), (typeof window!=='undefined' && window.__vsCheap) ? 1.0 : 0.0); // VS carve-cost profiling A/B
809
811
  gl.uniform1f(U('uBeachShelfM'), _g('beachShelf', 2400.0)); // land coastal shelf (geometry): h<S eased h*h/S = wide beach
810
812
  gl.uniform1f(U('uHiFreqCut'), _g('hiFreqCut', 0.25)); // 0.5->0.25 (2026-06-10 'blotchy' -- see setComposeHeightUniforms)
811
813
  gl.uniform1f(U('uVertexAO'), _g('vertexAO', 1.0)); // per-vertex shading/AO strength (DEFECT 2, 2026-06-06)
@@ -177,7 +177,7 @@ export async function initMapspinnerPlanet(gl, opts = {}) {
177
177
  // count (orbit 860->20, lowalt 1272->328). 1.0 is the calibrated default; override live
178
178
  // via window.__splitFactor.
179
179
  const splitFactor = opts.splitFactor ?? 1.0;
180
- const gridMeshSize = opts.gridMeshSize || 8; // 16->11 FPS lever (triangle-throughput bound, not ALU; GRID 8 jagged biome crossovers, see gl-render.js GRID)
180
+ const gridMeshSize = opts.gridMeshSize || 11; // 16->11 FPS lever (triangle-throughput bound, not ALU; GRID 8 jagged biome crossovers, see gl-render.js GRID)
181
181
 
182
182
  gl.getExtension('EXT_color_buffer_float'); // RGBA32F atlas render targets
183
183
  // OES_texture_float_linear lets the driver LINEAR-filter the RGBA32F HPF/elevation textures. When
@@ -198,6 +198,7 @@ float riverCarveM(vec3 dir, out float wet){
198
198
  float riverCarveM(vec3 dir){ float w; return riverCarveM(dir, w); }
199
199
  const float CANYON_INCISE_DEPTH = 1400.0; // metres at the gorge floor (user 2026-06-02: deepen+widen so canyons visibly sculpt the elevation; was 480m = invisible vs multi-km relief)
200
200
  uniform float canyonDepthMul; // LIVE canyon-depth lever (window.__canyonDepth; 1.0 default)
201
+ uniform float uVsCheap; // VS profiling: >0.5 skips all carves in composeHeight (window.__vsCheap; gpuTimer carve-cost A/B)
201
202
  // W5: uNrmGain deleted (only fed the removed VS slopeGain).
202
203
  uniform float uVertexAO; // per-vertex shading/AO strength lever (window.__vertexAO; 1.0 default)
203
204
  // SEPARATE WATER SURFACE (user 2026-06-11 'the ocean should be a separate surface'): the same
@@ -643,6 +644,10 @@ highp float composeHeight(vec3 dir0, highp vec2 faceLocal, float tileM){ // W7
643
644
  // Shore-gated (fades in over the first 250m of land) so the coastline and the flat water planes are
644
645
  // untouched and no noise islets pop offshore. The VS FD lit-normal picks it up automatically.
645
646
  h += detailFbm(dir0) * uDetailOverlay * 30.0 * step(0.0, h);
647
+ // VS-PROFILING GATE (2026-06-14): uVsCheap>0.5 returns BEFORE all the carves (valley/lake/river/
648
+ // canyon/cliff/dune) so gpuTimer can A/B the per-vertex CARVE cost (the doctrine's suspected
649
+ // dominant term). Transient profiling toggle (window.__vsCheap); 0 = full path (default).
650
+ if (uVsCheap > 0.5) return h;
646
651
  // FLAT-AREA VALLEY NETWORKS + LAKES (user 2026-06-13): incised valley systems in low-relief
647
652
  // plains. Replaces the old noise bumps with a ridge-field valley network for connected
648
653
  // linear depressions and lakes that fill the valley bottoms. Fades to zero by reliefMul ~0.5.
@@ -964,24 +969,20 @@ void main() {
964
969
  // so it never drops below the mesh cell (would re-alias) nor exceeds ~1/3 the tile.
965
970
  highp float nStepM = (uNrmStepM > 0.0) ? uNrmStepM : 300.0;
966
971
  highp float duP = clamp(nStepM / max(defOffset.z, 1.0), 1.0 / ((uGrid > 0.0) ? uGrid : 16.0), 0.34);
967
- // 3-TAP FORWARD (FPS push 2026-06-14: target 144fps): center + 2 FORWARD offsets, NOT the 5-tap
968
- // central. The central was added for jaggedness, but the actual jaggedness root was the dFdx(vH)
969
- // relief term (now removed) -- at the LOW-PASS step (duP ~300m >> vertex spacing) the forward vs
970
- // central asymmetry is negligible while it costs 3 composeHeight/vertex instead of 5 (-40% of the
971
- // dominant VS cost). Still captures vtxDisplace (faceWarp shifts both dir+faceLocal per tap).
972
- highp float hPU = 0.0, hPV = 0.0;
973
- highp vec3 dPU = dir0, dPV = dir0;
974
- int fdIters = (uGrid >= 0.0) ? 2 : 1; // 2 forward offset taps (+ center hN0) = 3-tap normal; runtime-bounded (FXC unroll-defeat)
972
+ highp float hPU = 0.0, hMU = 0.0, hPV = 0.0, hMV = 0.0;
973
+ highp vec3 dPU = dir0, dMU = dir0, dPV = dir0, dMV = dir0;
974
+ int fdIters = (uGrid >= 0.0) ? 4 : 1; // 4 offset taps; runtime-bounded (FXC unroll-defeat, see uOctMax)
975
975
  for (int i = 0; i < fdIters; i++) {
976
- highp vec2 off = (i == 0) ? vec2(duP, 0.0) : vec2(0.0, duP);
976
+ highp vec2 off = (i == 0) ? vec2(duP, 0.0) : (i == 1) ? vec2(-duP, 0.0) : (i == 2) ? vec2(0.0, duP) : vec2(0.0, -duP);
977
977
  highp vec2 fl = faceWarp((vertex.xy + off) * defOffset.z + defOffset.xy);
978
978
  highp vec3 dd = normalize(defLocalToWorld * vec3(fl, defRadius));
979
979
  highp float hh = composeHeight(dd, fl, defOffset.z);
980
- if (i == 0) { hPU = hh; dPU = dd; } else { hPV = hh; dPV = dd; }
980
+ if (i == 0) { hPU = hh; dPU = dd; } else if (i == 1) { hMU = hh; dMU = dd; }
981
+ else if (i == 2) { hPV = hh; dPV = dd; } else { hMV = hh; dMV = dd; }
981
982
  }
982
- highp vec3 wC = dir0 * (defRadius + hN0);
983
- highp vec3 wU = dPU * (defRadius + hPU), wV = dPV * (defRadius + hPV);
984
- vN = normalize(cross(wU - wC, wV - wC));
983
+ highp vec3 wPU = dPU * (defRadius + hPU), wMU = dMU * (defRadius + hMU);
984
+ highp vec3 wPV = dPV * (defRadius + hPV), wMV = dMV * (defRadius + hMV);
985
+ vN = normalize(cross(wPU - wMU, wPV - wMV));
985
986
  if (dot(vN, dir0) < 0.0) vN = -vN; // keep it outward (terrain has no overhangs)
986
987
  }
987
988
  highp float h = hN0;