clouds: intensify coverage, scale and detail

This commit is contained in:
Richard Zink committed 2026-10-12 14:55:32 +02:00
1 parent 8000c7be0e
commit cb847df3f5
2 files changed
+14 -14

No files matched your search

+13 -13
View File
@@ -182,20 +182,20 @@ var FRAG_SRC = [
'float cloudDensity(vec3 p, float baseThresh, float soft) {',
'float py = p.y + earthDrop(p.xz);',
'vec3 cp = vec3(p.x, py, p.z);',
'float n = fbm3(cp * 0.35 + vec3(0.0, 0.0, uTime * 0.06));',
'float n = fbm3(cp * 0.22 + vec3(0.0, 0.0, uTime * 0.05));',
// The detail octave weighs at most 0.20 and fades to zero with
// distance; past soft = 0.95 it contributes under 1 %, so the whole
// 4-octave lookup is skipped for the (numerous) far samples.
'if (soft < 0.45) {',
'float d = fbm3(cp * 1.15 + vec3(uTime * 0.04, 7.3, uTime * 0.03));',
'n = n + d * mix(0.12, 0.0, soft / 0.45);',
'if (soft < 0.75) {',
'float d = fbm3(cp * 1.80 + vec3(uTime * 0.045, 7.3, uTime * 0.035));',
'n = n + d * mix(0.22, 0.0, soft / 0.75);',
'}',
// Cloud layer between uCloudBot and uCloudTop, densest in the
// middle (bell curve). The layer follows the Earth curvature.
'float h = clamp((py - uCloudBot) / (uCloudTop - uCloudBot), 0.0, 1.0);',
'float profile = 4.0 * h * (1.0 - h); // bell curve',
'profile = max(profile, 0.0);',
'return smoothstep(baseThresh, baseThresh + 0.45 + soft * 0.35, n) * profile;',
'return smoothstep(baseThresh, baseThresh + 0.34 + soft * 0.28, n) * profile;',
'}',
// Star field: project ray onto a far sphere, hash-grid for
// positions. Visible above the horizon at night with a small
@@ -502,7 +502,7 @@ var FRAG_SRC = [
'float py = p.y + earthDrop(p.xz);',
'if (py > uCloudTop || py < uCloudBot - 0.1) break;',
'if (tTerrain > 0.0 && t >= tTerrain) break;',
'float cSoft = smoothstep(3.0, 14.0, t);',
'float cSoft = smoothstep(4.0, 18.0, t);',
'float d = cloudDensity(p, baseThresh, cSoft);',
'if (d > 0.02) {',
'float lit = clamp((py - uCloudBot) / ((uCloudTop - uCloudBot) * 1.167), 0.0, 1.0);',
@@ -537,7 +537,7 @@ var FRAG_SRC = [
'cloudCol = mix(uCloudShadow, uCloud, lit);',
'cloudCol = mix(cloudCol, uLight, max(0.15, uDayProgress) * 0.35 * lit);',
'}',
'float alpha = clamp(d * stepSize * 1.15, 0.0, 1.0);',
'float alpha = clamp(d * stepSize * 1.30, 0.0, 1.0);',
'cloudSum += cloudCol * alpha * trans;',
'trans *= (1.0 - alpha);',
'if (trans < 0.04) break;',
@@ -698,18 +698,18 @@ var CLOUD_SAMPLER_GLSL = [
'float cloudDensity(vec3 p, float baseThresh, float soft) {',
'float py = p.y + earthDrop(p.xz);',
'vec3 cp = vec3(p.x, py, p.z);',
'float n = fbm3(cp * 0.35 + vec3(0.0, 0.0, uTime * 0.06));',
'float n = fbm3(cp * 0.22 + vec3(0.0, 0.0, uTime * 0.05));',
// The detail octave weighs at most 0.20 and fades to zero with
// distance; past soft = 0.95 it contributes under 1 %, so the whole
// 4-octave lookup is skipped for the (numerous) far samples.
'if (soft < 0.45) {',
'float d = fbm3(cp * 1.15 + vec3(uTime * 0.04, 7.3, uTime * 0.03));',
'n = n + d * mix(0.12, 0.0, soft / 0.45);',
'if (soft < 0.75) {',
'float d = fbm3(cp * 1.80 + vec3(uTime * 0.045, 7.3, uTime * 0.035));',
'n = n + d * mix(0.22, 0.0, soft / 0.75);',
'}',
'float h = clamp((py - uCloudBot) / (uCloudTop - uCloudBot), 0.0, 1.0);',
'float profile = 4.0 * h * (1.0 - h);',
'profile = max(profile, 0.0);',
'return smoothstep(baseThresh, baseThresh + 0.45 + soft * 0.35, n) * profile;',
'return smoothstep(baseThresh, baseThresh + 0.34 + soft * 0.28, n) * profile;',
'}',
].join('\n');
@@ -808,7 +808,7 @@ var TERRAIN_FRAG_SRC = [
'float dens = 0.0;',
'for (int ci = 0; ci < 5; ci++) {',
'float tt = mix(tBot, tTop, (float(ci) + 0.5) / 5.0);',
'dens += cloudDensity(vWorld + uSunDir * tt, baseTh, smoothstep(3.0, 14.0, tt));',
'dens += cloudDensity(vWorld + uSunDir * tt, baseTh, smoothstep(4.0, 18.0, tt));',
'}',
'cShadow = mix(uCloudShadowFloor, 1.0,',
' exp(-dens * uCloudShadowDensity));',