mapspinner 0.1.67 → 0.1.69

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.67",
3
+ "version": "0.1.69",
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
@@ -1051,7 +1051,7 @@ export async function initMapspinnerRender(gl, opts = {}) {
1051
1051
  gl.uniform1f(U('oceanAmp'), (oc.oceanAmplitude != null) ? oc.oceanAmplitude : 1.0);
1052
1052
  gl.uniform1f(U('oceanChoppy'), (oc.oceanChoppiness != null) ? oc.oceanChoppiness : 0.5);
1053
1053
  gl.uniform1f(U('oceanFoam'), (oc.oceanFoam != null) ? oc.oceanFoam : 0.5);
1054
- gl.uniform1f(U('uBeachTopM'), _g('beachTop', 80.0)); // beach ceiling: grass stops, sand to the waterline + under it. 30->90 (user 2026-06-14: 3x beach width)
1054
+ gl.uniform1f(U('uBeachTopM'), _g('beachTop', 640.0)); // beach ceiling: grass stops, sand to the waterline + under it. 30->90 (user 2026-06-14: 3x beach width)
1055
1055
 
1056
1056
  // SINGLE INSTANCED DRAW: the deform params that were per-quad uniforms (ox,oy,l,level + face)
1057
1057
  // are now PER-INSTANCE attributes. Build one interleaved instance buffer [ox,oy,l,level,face]
@@ -1812,7 +1812,7 @@ void main() {
1812
1812
  // displacement height-blend (small bw below) so sand vs grass is a sharp choice distributed by
1813
1813
  // texture relief = interlocking fingers that thin out with height, never a blendy fade.
1814
1814
  float beachW = warpN * uBeachTopM * 0.30; // warp amplitude scales with the beach band height
1815
- float beach = (1.0 - smoothstep(beachW, uBeachTopM * 2.5 + beachW, vH))
1815
+ float beach = (1.0 - smoothstep(beachW, uBeachTopM * 0.5 + beachW, vH)) // 2.0->0.5x: 4x narrower grass<->sand crossover band (user 2026-06-14)
1816
1816
  * (1.0 - smoothstep(0.18, 0.55, slope));
1817
1817
  // SAND BLEED (2026-06-13): patchy sand spills above the main beach line, modulated by VS
1818
1818
  // warp noise so the edge reads as wind-blown pockets, not a strict elevation cut. At peak it
@@ -1905,6 +1905,11 @@ void main() {
1905
1905
  vec3 cA = vec3(dot(albA.rgb, LUMA));
1906
1906
  vec3 nA = surfTriNrm(uSurfNrm, wt4, tw, lA, n) * 1.4 + surfTriNrm(uSurfNrm, wt, tw, lA, n) * 0.8; // high + low-octave normal
1907
1907
  float dispA = albA.a;
1908
+ // NO BIOME COLOR INHERITANCE (user 2026-06-14 'take away all biome color inheritance, it will
1909
+ // speed it up' -- and fixes 'sand near grass tinted green'): each layer wears its OWN material
1910
+ // color (grass/rock/sand/snow), NOT the macro biome color. mcA = layer A's base color.
1911
+ vec3 mcA = lA < 0.5 ? bcGrass : (lA < 1.5 ? bcRock : (lA < 2.5 ? bcShore : bcSnow));
1912
+ vec3 texMatColor = mcA;
1908
1913
  vec4 texAlb = vec4(cA, dispA); vec3 texNrm = nA;
1909
1914
  float splatRock = (abs(lA - 1.0) < 0.5) ? 1.0 : 0.0; // height-blend rock fraction (layer 1 = rock)
1910
1915
  if (wB > 0.02) { // second layer only where a real transition exists
@@ -1921,21 +1926,32 @@ void main() {
1921
1926
  // crossovers'): a weaker weight ramp lets the DISPLACEMENT decide the winner over a WIDER
1922
1927
  // weight range, so the near-hard displacement-driven distribution spans a broad margin for
1923
1928
  // EVERY pair (rock-slope, snow, biome...), not just the explicitly-widened beach gate.
1924
- float hA = dispA + (bAB - 0.5) * 0.5;
1925
- float hB = dispB + (0.5 - bAB) * 0.5;
1929
+ // AMPLIFY the displacement's influence (user 2026-06-14 'the high-freq textures arent
1930
+ // affecting the crossover point yet'): the raw displacement sits near its 0.5 mean so the
1931
+ // per-layer DIFFERENCE was tiny -> the crossover was weight-driven, not texture-driven. Center
1932
+ // + scale it (x3) so the high-freq relief clearly decides the boundary; the weight just
1933
+ // positions it. (Mips average the displacement to ~0.5 at distance -> auto-smooth far edge.)
1934
+ // NON-LINEAR weight ramp (user 2026-06-14 'the ramp isnt complete enough between sections ->
1935
+ // cutoff lines at the end'): a CONSTANT weight bias let displacement fingers survive right up
1936
+ // to where the gate drops the layer = a hard cutoff line. Make the bias WEAK mid-ramp (wide
1937
+ // displacement crossover) and STRONG at the ends so the fingers taper to nothing before the
1938
+ // gate cuts off -> the ramp completes smoothly, no end line.
1939
+ float wRamp = (bAB - 0.5) * mix(1.4, 4.0, clamp(abs(bAB - 0.5) * 2.0, 0.0, 1.0)); // mid 0.6->1.4 (user 2026-06-14 'all crossover bands a bit wide, rock too'): stronger weight bias = NARROWER displacement crossover on every pair
1940
+ float hA = (dispA - 0.5) * 3.0 + wRamp;
1941
+ float hB = (dispB - 0.5) * 3.0 - wRamp;
1926
1942
  float mh = max(hA, hB) - bw;
1927
1943
  float waH = max(hA - mh, 0.0), wbH = max(hB - mh, 0.0);
1928
1944
  float bSharp = waH / max(waH + wbH, 1e-4);
1929
1945
  texAlb = vec4(mix(cB, cA, bSharp), mix(dispB, dispA, bSharp));
1930
1946
  texNrm = mix(nB, nA, bSharp);
1931
- splatRock = (abs(lA - 1.0) < 0.5 ? bSharp : 0.0) + (abs(lB - 1.0) < 0.5 ? (1.0 - bSharp) : 0.0);
1947
+ vec3 mcB = lB < 0.5 ? bcGrass : (lB < 1.5 ? bcRock : (lB < 2.5 ? bcShore : bcSnow));
1948
+ texMatColor = mix(mcB, mcA, bSharp); // height-blended MATERIAL color (no biome)
1932
1949
  }
1933
1950
  // MATCH COLOR TO NORMAL (user 2026-06-14 'green grassy patches with the rock normals -- should be
1934
1951
  // rock colored or grass normals'): texNrm follows the displacement height-blend (rock on bumps in
1935
1952
  // the slope-transition band) but the macro albedo used the slope gate -> grass color under a rock
1936
1953
  // normal. Push the macro color toward bcRock by the splat's actual rock fraction so the COLOR
1937
1954
  // follows the same selection the NORMAL does (bounded -- splatRock is 0 where rock isn't in top-2).
1938
- albedo = mix(albedo, bcRock, splatRock * 0.8);
1939
1955
  float k = uTexMix * texFarFade;
1940
1956
  // macro-tinted detail (user 2026-06-10 'the textured patch must be tinted to the same shade
1941
1957
  // as the spot its replacing'): the texture contributes STRUCTURE + relative chroma only,
@@ -1949,7 +1965,7 @@ void main() {
1949
1965
  // deviation visible while the patch average lands exactly on the macro shade.
1950
1966
  float mA = uSurfMeanL[int(lA + 0.5)];
1951
1967
  float texL = wB > 0.02 ? mix(uSurfMeanL[int(lB + 0.5)], mA, bAB) : mA;
1952
- vec3 detail = texC * (albedo / max(texL, 0.02));
1968
+ vec3 detail = texC * (texMatColor / max(texL, 0.02)); // MATERIAL color * structure (no biome inheritance)
1953
1969
  // ROCK SHOWS THE TRUE PHOTO (user 2026-06-10 'we still see the original rock texture --
1954
1970
  // replace completely'): tinting rock to the macro shade just reproduced the old grey/tan,
1955
1971
  // so the rock layer takes the raw photo color; grass/sand/snow stay shade-matched.
@@ -1966,8 +1982,9 @@ void main() {
1966
1982
  // low-freq albedo is now NORMALS-ONLY (texC is luma structure), so the old raw-photo 'identity'
1967
1983
  // hue is gone; texIdent == detail = MACRO color * structure (keeps rock its macro tan-grey, not
1968
1984
  // grey). The 4x detail carries the fine structure for every material.
1969
- vec3 texIdent = texC * (albedo / max(texL, 0.02));
1970
- albedo = clamp(mix(albedo, mix(detail, texIdent, photoF), k), 0.0, 1.0);
1985
+ // base = flat MATERIAL color (far/low-k); near = structured detail. The macro biome albedo is no
1986
+ // longer the base, so NO biome color bleeds into the ground (user 'take away all biome inheritance').
1987
+ albedo = clamp(mix(texMatColor, detail, k), 0.0, 1.0);
1971
1988
  // FAKE MIDDAY AO from the displacement (user 2026-06-14 'darken the deepest parts of the
1972
1989
  // displacement textures a little'): the texture's LOWEST displacement = crevices/pits; darken
1973
1990
  // them ~18% so the surface reads as sunlit-from-above with soft self-occlusion in the lows.