Tune clouds3d for low-end GPUs: 18 steps, 3 octaves

Reduce raymarch iterations from 28 to 18 and fBm octaves from
4 to 3 (with step size 0.55->0.85 to preserve cloud coverage).
Per-pixel cost drops by ~55% while visual density stays similar.
This commit is contained in:
Richard Zink committed 2026-10-07 18:56:40 +02:00
1 parent 0648676974
commit 433d743446
1 file changed
+6 -4
+6 -4
View File
@@ -44,7 +44,9 @@ var VERT_SRC = [
].join('\n'); ].join('\n');
// Volumetric raymarch through a horizontal cloud layer. // Volumetric raymarch through a horizontal cloud layer.
// Cheap 3D value noise + 4-octave fbm. 28 raymarch steps. // Cheap 3D value noise + 3-octave fbm. 18 raymarch steps.
// Tuned for low-end hardware: fewer steps + fewer noise samples
// per step keep the frame within budget on integrated GPUs.
// Camera path is sinusoidal so the view occasionally dips // Camera path is sinusoidal so the view occasionally dips
// into the cloud deck for the "fly through the edges" feel. // into the cloud deck for the "fly through the edges" feel.
var FRAG_SRC = [ var FRAG_SRC = [
@@ -79,7 +81,7 @@ var FRAG_SRC = [
'float fbm3(vec3 p) {', 'float fbm3(vec3 p) {',
'float v = 0.0;', 'float v = 0.0;',
'float a = 0.5;', 'float a = 0.5;',
'for (int i = 0; i < 4; i++) {', 'for (int i = 0; i < 3; i++) {',
'v += a * noise3(p);', 'v += a * noise3(p);',
'p = p * 2.03 + vec3(13.7, 7.1, 19.3);', 'p = p * 2.03 + vec3(13.7, 7.1, 19.3);',
'a *= 0.5;', 'a *= 0.5;',
@@ -119,10 +121,10 @@ var FRAG_SRC = [
'float baseThresh = mix(0.72, 0.40, uDensity);', 'float baseThresh = mix(0.72, 0.40, uDensity);',
// March the cloud layer (bounded in Y). // March the cloud layer (bounded in Y).
'float t = 0.0;', 'float t = 0.0;',
'float stepSize = 0.55;', 'float stepSize = 0.85;',
'float trans = 1.0;', 'float trans = 1.0;',
// Pre-compute ray entry/exit on cloud layer for early out // Pre-compute ray entry/exit on cloud layer for early out
'for (int i = 0; i < 28; i++) {', 'for (int i = 0; i < 18; i++) {',
'vec3 p = ro + rd * t;', 'vec3 p = ro + rd * t;',
'if (p.y > 2.0 || p.y < -0.4) break;', 'if (p.y > 2.0 || p.y < -0.4) break;',
'float d = cloudDensity(p, baseThresh);', 'float d = cloudDensity(p, baseThresh);',