mapspinner 0.1.46 → 0.1.48

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.46",
3
+ "version": "0.1.48",
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
@@ -421,7 +421,8 @@ export async function initMapspinnerRender(gl, opts = {}) {
421
421
  gl.uniform1f(loc('vtxDetail'), g('vtxDetail', 1.0)); // DECISIVE: vtxDisplace strength (early-return on 0)
422
422
  gl.uniform1f(loc('canyonDepthMul'), g('canyonDepth', 1.0));
423
423
  gl.uniform1f(loc('uVsCheap'), (typeof window!=='undefined' && window.__vsCheap) ? 1.0 : 0.0); // VS carve-cost profiling A/B
424
- gl.uniform1f(loc('uBeachShelfM'), g('beachShelf', 28000.0)); // land coastal shelf (geometry); probe MUST match render
424
+ gl.uniform1f(loc('uBeachShelfM'), g('beachShelf', 0.0)); // land coastal shelf (geometry); probe MUST match render
425
+ gl.uniform1f(loc('uLandBias'), g('landBias', 0.0)); // +650m hypsometry bias = ~+30% land:sea (measured: landFrac 0.041 -> 0.054 over a 700-dir sphere grid, user 2026-06-14). window.__landBias dials it live.
425
426
  gl.uniform1f(loc('cliffAmt'), g('cliffAmt', 1.0));
426
427
  gl.uniform1i(loc('uFloatLinearOK'), _halfFloatLinearOK ? 1 : 0);
427
428
  // FXC unroll-defeat (2026-06-12 AMD d3d11 fix): runtime octave bound for broadShapeM; the shader
@@ -960,7 +961,8 @@ export async function initMapspinnerRender(gl, opts = {}) {
960
961
  const _g = (n,d)=> (typeof window!=='undefined' && window['__'+n]!=null) ? +window['__'+n] : d;
961
962
  gl.uniform1f(U('canyonDepthMul'), _g('canyonDepth', 1.0));
962
963
  gl.uniform1f(U('uVsCheap'), (typeof window!=='undefined' && window.__vsCheap) ? 1.0 : 0.0); // VS carve-cost profiling A/B
963
- gl.uniform1f(U('uBeachShelfM'), _g('beachShelf', 28000.0)); // land coastal shelf (geometry): h<S eased h*h/S = wide beach
964
+ gl.uniform1f(U('uBeachShelfM'), _g('beachShelf', 0.0)); // land coastal shelf (geometry): h<S eased h*h/S = wide beach
965
+ gl.uniform1f(U('uLandBias'), _g('landBias', 0.0)); // +650m hypsometry bias = ~+30% land:sea (window.__landBias); MUST match the probe (setComposeHeightUniforms) for collision parity
964
966
  gl.uniform1f(U('uHiFreqCut'), _g('hiFreqCut', 0.25)); // 0.5->0.25 (2026-06-10 'blotchy' -- see setComposeHeightUniforms)
965
967
  gl.uniform1f(U('uVertexAO'), _g('vertexAO', 1.0)); // per-vertex shading/AO strength (DEFECT 2, 2026-06-06)
966
968
  gl.uniform1f(U('cliffAmt'), _g('cliffAmt', 1.0));
@@ -210,6 +210,7 @@ uniform float uIsWater; // 0 = terrain pass, 1 = water-surfac
210
210
  uniform float uUnderwater; // 0 = camera above water, 1 = camera below sea level
211
211
  uniform float uBeachTopM; // beach ceiling (m): below this, grass/snow yield to sand (window.__beachTop; 30 default)
212
212
  uniform float uBeachShelfM; // land coastal-shelf top (m): h<this is eased (h*h/S) so the coast rises gently from the waterline = wide beach (window.__beachShelf; 300 default). GEOMETRY (composeHeight+vH).
213
+ uniform float uLandBias; // metres added to h (cbias+bShape) BEFORE the sea/land split -> raises the hypsometry = MORE LAND vs sea (window.__landBias). composeHeight + VS mirror + probe all add it (parity).
213
214
  uniform float uHiFreqCut; // hi-freq elevation-noise attenuation, applied to ALL hi-freq sources:
214
215
  // broadShapeM/MD fine octaves (o>=6) + vtxDisplace micro-relief
215
216
  // (window.__hiFreqCut; default 0.25 = the user's 4x reduction, 2026-06-06)
@@ -615,7 +616,7 @@ highp float composeHeight(vec3 dir0, highp vec2 faceLocal, float tileM){ // W7
615
616
  ridgeMul = mix(ridgeMul, max(ridgeMul, 0.9 * volcanic), isleZone);
616
617
  }
617
618
  highp float bShape = broadShapeM(dir0, reliefMul, ridgeMul); // W7: metres
618
- highp float h = cbias + bShape; // W7: composite elevation metres (~13000)
619
+ highp float h = cbias + bShape + uLandBias; // W7: composite elevation metres (~13000); +uLandBias raises hypsometry = more land
619
620
  // REALISTIC BATHYMETRY (user 2026-06-11 'the depth under the water doesnt seem right -- the
620
621
  // landscape should continue underwater realistically'): raw cbias+bShape plunges at land-relief
621
622
  // gradients, so the seabed hit kilometre depths within sight of the beach. Real margins have a
@@ -626,11 +627,13 @@ highp float composeHeight(vec3 dir0, highp vec2 faceLocal, float tileM){ // W7
626
627
  // C1 WATERLINE (user 2026-06-14 'geometry crease + shading/rock hard line where land meets beach'):
627
628
  // the land shelf is FLAT at the waterline (slope 0) but the seabed used slope 0.24 from h=0 -> a
628
629
  // slope discontinuity = a crease (+ the shading brightness line + rock where steep) right at the
629
- // shore. Ease the shallow seabed with the SAME flat-at-waterline shelf curve (mirror of the land
630
- // side) before the 0.24/1.19 bathymetry, so BOTH sides meet the waterline with slope 0 = no crease.
631
- highp float bShelfS = uBeachShelfM > 1.0 ? uBeachShelfM : 600.0;
630
+ // shore. Ease ONLY a NARROW band of depth (NOT the 28km land beach width -- that shallowed the
631
+ // whole ocean into 'almost-land everywhere', user 2026-06-14) with the flat-at-waterline curve so
632
+ // both sides meet the waterline at slope 0 (no crease); beyond SEABED_EASE the true bathymetry
633
+ // resumes so the ocean goes DEEP.
634
+ const highp float SEABED_EASE = 300.0; // metres of depth flattened at the shore (decoupled from the land beach)
632
635
  highp float d0 = -h;
633
- highp float d = (d0 < bShelfS) ? (d0 * d0 / bShelfS) * (2.0 - d0 / bShelfS) : d0;
636
+ highp float d = (d0 < SEABED_EASE) ? (d0 * d0 / SEABED_EASE) * (2.0 - d0 / SEABED_EASE) : d0;
634
637
  h = -(min(d, 500.0) * 0.24 + max(d - 500.0, 0.0) * 1.19);
635
638
  h = max(h, -11000.0); // cap depth at Mariana Trench (~11km)
636
639
  } else {
@@ -855,13 +858,13 @@ void main() {
855
858
  // entire silhouette+hypsometry. The old wasm upsample-and-add cascade (zfc.x) was REMOVED -- it
856
859
  // was a SECOND shape source that diverged per-LOD (the detail-inversion root). bShape amplitude
857
860
  // was retuned (A0 6500, off -900) so this single field hits Earth hypso without the cascade.
858
- vH = cbias + bShape;
861
+ vH = cbias + bShape + uLandBias; // +uLandBias (mirror composeHeight) -> more land vs sea
859
862
  // shelf/slope bathymetry remap + underwater displacement -- MUST mirror composeHeight exactly
860
863
  // (this is the FS-material running value; composeHeight is the geometry/probe height).
861
864
  if (vH < 0.0) {
862
- highp float bShelfS = uBeachShelfM > 1.0 ? uBeachShelfM : 600.0; // C1 waterline -- mirror composeHeight exactly
865
+ const highp float SEABED_EASE = 300.0; // mirror composeHeight: narrow waterline ease, deep ocean beyond
863
866
  highp float dSea0 = -vH;
864
- highp float dSea = (dSea0 < bShelfS) ? (dSea0 * dSea0 / bShelfS) * (2.0 - dSea0 / bShelfS) : dSea0;
867
+ highp float dSea = (dSea0 < SEABED_EASE) ? (dSea0 * dSea0 / SEABED_EASE) * (2.0 - dSea0 / SEABED_EASE) : dSea0;
865
868
  vH = -(min(dSea, 500.0) * 0.24 + max(dSea - 500.0, 0.0) * 1.19);
866
869
  vH = max(vH, -11000.0); // cap depth at Mariana Trench (~11km)
867
870
  } else {
@@ -2155,11 +2158,14 @@ void main() {
2155
2158
  highp vec3 segKm = pAtm - camA;
2156
2159
  highp float dKm = length(segKm);
2157
2160
  float depth = max(0.0, terrainR - length(camWorld));
2158
- // Water absorption coefficients (per km): red attenuates fastest, blue slowest.
2159
- vec3 absorb = vec3(4.0, 0.8, 0.3) * (1.0 + depth * 0.0003);
2161
+ // CLEARER WATER + LONG VISIBILITY (user 2026-06-14 'fix underwater visibility so we can explore
2162
+ // under the ocean'): the old absorb (4,0.8,0.3)/km + a 50->500m hard fog fade closed the view to
2163
+ // opaque blue within ~500m. Lower the coefficients (still red-first absorption) and push the hard
2164
+ // fade to ~3-15km so the seabed landscape is explorable; red still fades fast (realistic blue cast).
2165
+ vec3 absorb = vec3(1.0, 0.30, 0.15) * (1.0 + depth * 0.0002);
2160
2166
  vec3 uwTrans = exp(-absorb * dKm);
2161
- vec3 uwFog = vec3(0.002, 0.06, 0.16) + vec3(0.0, 0.02, 0.04) * depth / 1000.0;
2162
- color = mix(color * uwTrans + uwFog * (1.0 - uwTrans), uwFog, smoothstep(50.0, 500.0, dKm * 1000.0));
2167
+ vec3 uwFog = vec3(0.004, 0.10, 0.22) + vec3(0.0, 0.02, 0.04) * depth / 1000.0;
2168
+ color = mix(color * uwTrans + uwFog * (1.0 - uwTrans), uwFog, smoothstep(3000.0, 15000.0, dKm * 1000.0));
2163
2169
  }
2164
2170
  // RIVERS post-lighting (witnessed browser-2115/2118: the river-blue in ALBEDO is multiplied
2165
2171
  // by the warm sun irradiance (sunIrr.b is low) so land rivers lose their blue in the lit