mapspinner 0.1.52 → 0.1.54

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.52",
3
+ "version": "0.1.54",
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
@@ -1115,11 +1115,11 @@ export async function initMapspinnerRender(gl, opts = {}) {
1115
1115
  // shows. Cap every visible leaf at level WCAP and DEDUP to its ancestor tile: a coarse,
1116
1116
  // LOD-churn-free cover of the same footprint, typically ~10-50x fewer water vertices.
1117
1117
  // __waterSurface=0 disables live.
1118
- // UNDERWATER: skip the sea-level water surface entirely (user 2026-06-14 'underwater looks weird,
1119
- // we cant see anything / it must draw the sea bed'). The surface mesh drawn from below was an
1120
- // opaque sheet that occluded the seabed; with it gone, the underwater camera sees the seabed
1121
- // terrain directly (with the underwater fog). Above water it draws normally.
1122
- if ((typeof window === 'undefined' || window.__waterSurface !== false) && !_uw) {
1118
+ // The water surface draws in BOTH cases now (user 2026-06-14 'no water surface visible from
1119
+ // underneath'): it's geometrically ABOVE the camera, so underwater it is the up-view CEILING
1120
+ // (Snell's window, shaded in the uUnderwater branch) and the seabed below stays visible (the
1121
+ // down-view ray never hits the surface). With the fog 10x lighter it no longer washes the floor.
1122
+ if (typeof window === 'undefined' || window.__waterSurface !== false) {
1123
1123
  // WCAP 7 -> 9 (coast witness caught it: a level-7 tile's 16-cell mesh chord sags
1124
1124
  // A_cell^2/(8R) ~ 0.8m below the true sphere mid-cell -- BELOW the metres-deep shelf
1125
1125
  // seabed, so the depth test culled the water across entire shorelines. Level-9 cells
@@ -1560,6 +1560,16 @@ void main() {
1560
1560
  vec3 deepBlue = vec3(0.005, 0.06, 0.18);
1561
1561
  vec3 waveBright = vec3(0.0, 0.02, 0.06) * length(slopeW);
1562
1562
  vec3 wcol = deepBlue + sunUnder * 0.4 + waveBright;
1563
+ // SNELL'S WINDOW (user 2026-06-14 'no water surface visible from underneath'): looking UP, the
1564
+ // surface is a bright window to the sky within the critical angle (near-vertical view) and a
1565
+ // dark total-internal-reflection mirror at grazing angles. upness = how vertical the view->
1566
+ // surface ray is; brighten toward the refracted sky + a sun disc inside the window.
1567
+ float upness = abs(dot(viewW, wn));
1568
+ float snell = smoothstep(0.50, 0.82, upness);
1569
+ vec3 skyWindow = vec3(0.40, 0.60, 0.85) * (0.5 + 0.9 * ndl);
1570
+ wcol = mix(wcol, skyWindow, snell * 0.85);
1571
+ float sunw = pow(max(dot(viewW, sunDir), 0.0), 180.0); // sun seen through the window
1572
+ wcol += vec3(1.0, 0.92, 0.70) * sunw * (0.4 + 0.6 * snell);
1563
1573
  float macroMuW = dot(uz, sunDir);
1564
1574
  float dayShadeW = mix(uNightFloor, 1.0, smoothstep(-uTermWidth, uTermWidth, macroMuW));
1565
1575
  vec3 cW = wcol * dayShadeW * uExposure;
@@ -2179,10 +2189,22 @@ void main() {
2179
2189
  // under the ocean'): the old absorb (4,0.8,0.3)/km + a 50->500m hard fog fade closed the view to
2180
2190
  // opaque blue within ~500m. Lower the coefficients (still red-first absorption) and push the hard
2181
2191
  // fade to ~3-15km so the seabed landscape is explorable; red still fades fast (realistic blue cast).
2182
- vec3 absorb = vec3(1.0, 0.30, 0.15) * (1.0 + depth * 0.0002);
2192
+ // MUCH CLEARER (user 2026-06-14 'we cant see the ocean floor properly'): the deep-ocean floor is
2193
+ // km below, so even 'clear' (1.0/0.30/0.15) water + a 3-15km fade hid it. Drop the coefficients
2194
+ // hard and push the fade to ~10-50km so the ocean FLOOR reads as terrain from a long way off
2195
+ // (game-clarity over physical realism; red still absorbs first for a natural blue-green cast).
2196
+ // FOG 10x LESS (user 2026-06-14 'make the fog 10x less / doesnt look right under the water'):
2197
+ // extinction /10 and the hard fade pushed 10x out so the ocean floor reads clearly from a long
2198
+ // way off with only a faint blue tint, not a wash of fog.
2199
+ vec3 absorb = vec3(0.035, 0.010, 0.005) * (1.0 + depth * 0.0001);
2183
2200
  vec3 uwTrans = exp(-absorb * dKm);
2184
- vec3 uwFog = vec3(0.004, 0.10, 0.22) + vec3(0.0, 0.02, 0.04) * depth / 1000.0;
2185
- color = mix(color * uwTrans + uwFog * (1.0 - uwTrans), uwFog, smoothstep(3000.0, 15000.0, dKm * 1000.0));
2201
+ vec3 uwFog = vec3(0.004, 0.09, 0.18) + vec3(0.0, 0.015, 0.03) * depth / 1000.0;
2202
+ // SEABED LIGHTING (user 'floor too flat/dim'): the deep floor gets almost no direct sun, so it
2203
+ // read dim+flat. Lift the brightness and add an up-facing fill (brighter where the surface faces
2204
+ // up, darker on slopes -> 3D relief) + a touch of slope contrast keyed on the lit normal vNrm.
2205
+ float upFill = mix(0.75, 1.35, clamp(dot(vNrm, normalize(vWorld)) * 0.5 + 0.5, 0.0, 1.0));
2206
+ color *= upFill * 1.5;
2207
+ color = mix(color * uwTrans + uwFog * (1.0 - uwTrans), uwFog, smoothstep(100000.0, 500000.0, dKm * 1000.0));
2186
2208
  }
2187
2209
  // RIVERS post-lighting (witnessed browser-2115/2118: the river-blue in ALBEDO is multiplied
2188
2210
  // by the warm sun irradiance (sunIrr.b is low) so land rivers lose their blue in the lit