From 1879a6912af8515e35c9dfaa490f1e8589eb0a07 Mon Sep 17 00:00:00 2001 From: Richard Zink Date: Sat, 10 Oct 2026 11:12:38 +0200 Subject: [PATCH] contrails: distance-scaled ribbon width (sub-pixel fix), brighter head, far longer visible range --- vendor/clouds3d.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/vendor/clouds3d.js b/vendor/clouds3d.js index 68c85d6..16b3c09 100644 --- a/vendor/clouds3d.js +++ b/vendor/clouds3d.js @@ -2892,13 +2892,13 @@ var CT_FRAG_SRC = [ 'float dens = 0.62 + 0.38 * sin(along) * sin(along * 2.7 + 1.3);', 'if (dens < 0.0) dens = 0.0;', // eroded, uneven edges: the stripe narrows and widens along u - 'float wob = 0.45 + 0.55 * (0.5 + 0.5 * sin(along * 3.1 + 7.0));', + 'float wob = 0.55 + 0.45 * (0.5 + 0.5 * sin(along * 3.1 + 7.0));', 'float side = abs(vV);', - 'float edge = 1.0 - smoothstep(wob * 0.30, wob, side);', + 'float edge = 1.0 - smoothstep(wob * 0.22, wob, side);', // older tail also thins out across its width - 'edge *= 0.35 + 0.65 * pow(vU, 0.6);', + 'edge *= 0.45 + 0.55 * pow(vU, 0.6);', 'if (edge <= 0.0) discard;', - 'float a = vS * pow(vU, 1.25) * 0.95 * dens * edge;', + 'float a = vS * pow(vU, 1.15) * 1.15 * dens * edge;', 'if (a <= 0.004) discard;', 'gl_FragColor = vec4(0.95, 0.96, 1.0, a);', '}' @@ -3774,11 +3774,13 @@ window.clouds3dRender = function(target) { fltLegAt(stc.leg, stc.s - tl * 0.5, _cs); var cdx = _cs.x - camX, cdy = stc.y - camY, cdz = _cs.z - camZ; var distc = Math.sqrt(cdx * cdx + cdy * cdy + cdz * cdz); - // gentle distance thinning only - trails should stay - // readable across the whole visible sky - var dfc = 1 - (distc - 12) / 12; + // gentle distance thinning only + var dfc = 1 - (distc - 16) / 10; if (dfc > 1) dfc = 1; else if (dfc <= 0.02) continue; - var strg = gt * dayf * dfc * 0.9; + var strg = gt * dayf * dfc; + // widen with distance: a fixed 310 m ribbon is sub-pixel at + // 150 km and blends away; grow it to hold ~2-4 screen px + var hw = CT_HALF_W + distc * 0.0025; var ph = fltData[cj].phase; var hy = stc.y; var prev = null, cur = _sk0; @@ -3787,7 +3789,7 @@ window.clouds3dRender = function(target) { if (dd < 0) dd = 0; fltLegAt(stc.leg, dd, _cs); cur.x = _cs.x; cur.z = _cs.z; - cur.px = _cs.tz * CT_HALF_W; cur.pz = -_cs.tx * CT_HALF_W; + cur.px = _cs.tz * hw; cur.pz = -_cs.tx * hw; cur.u = sk / CT_SEG; if (prev) { _ctVert(prev.x + prev.px, hy, prev.z + prev.pz, prev.u, 1, strg, ph);