From cf5f8c211355c0beb9d47ddb59d4d58da5bafc6f Mon Sep 17 00:00:00 2001 From: Rezmason Date: Sat, 23 Oct 2021 01:12:31 -0700 Subject: [PATCH] Simplifying rainPass.compute's weirder operations. --- TODO.txt | 13 +++++-------- js/config.js | 2 +- shaders/rainPass.compute | 16 ++++++++++------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/TODO.txt b/TODO.txt index deb6f28..dc6e6a1 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,13 +1,10 @@ TODO: -Improve forkability - Refactor rainPass.compute's sin(sqrt(5)) stuff, there must be a clearer expression - - Write an explanation of the rain pass (and include images) - Compute - Volumetric quads - Fullscreen quad and spacial mapping - MSDFs +Write an explanation of the rain pass (and include images) + Compute + Volumetric quads + Fullscreen quad and spacial mapping + MSDFs Resurrection Modified glyph order? diff --git a/js/config.js b/js/config.js index 3e4a571..95b939f 100644 --- a/js/config.js +++ b/js/config.js @@ -72,7 +72,7 @@ const versions = { bloomStrength: 0.75, highPassThreshold: 0.0, cycleSpeed: 0.2, - cycleFrameSkip: 6, + cycleFrameSkip: 8, cycleStyleName: "cycleRandomly", cursorEffectThreshold: 0.64, brightnessOverride: 0.22, diff --git a/shaders/rainPass.compute b/shaders/rainPass.compute index 63680c0..51638fc 100644 --- a/shaders/rainPass.compute +++ b/shaders/rainPass.compute @@ -40,20 +40,24 @@ vec2 randomVec2( const in vec2 uv ) { return fract(vec2(sin(uv.x * 591.32 + uv.y * 154.077), cos(uv.x * 391.32 + uv.y * 49.077))); } +float wobble(float x) { + return x + 0.3 * sin(SQRT_2 * x) + 0.2 * sin(SQRT_5 * x); +} + // Core functions // Rain time is the shader's key underlying concept. // It's why glyphs that share a column are lit simultaneously, and are brighter toward the bottom. float getRainTime(float simTime, vec2 glyphPos) { - float columnTimeOffset = randomFloat(vec2(glyphPos.x, 0.)); - float columnSpeedOffset = randomFloat(vec2(glyphPos.x + 0.1, 0.)); + float columnTimeOffset = randomFloat(vec2(glyphPos.x, 0.)) * 1000.; + float columnSpeedOffset = randomFloat(vec2(glyphPos.x + 0.1, 0.)) * 0.5 + 0.5; // columnSpeedOffset = 0.; // TODO: loop - float columnTime = (columnTimeOffset * 1000. + simTime * 0.5 * fallSpeed) * (0.5 + columnSpeedOffset * 0.5) + (sin(simTime * fallSpeed * columnSpeedOffset) * 0.2); + float columnTime = columnTimeOffset + simTime * fallSpeed * columnSpeedOffset; return (glyphPos.y * 0.01 + columnTime) / raindropLength; } float getBrightness(float rainTime) { - float value = 1. - fract((rainTime + 0.3 * sin(SQRT_2 * rainTime) + 0.2 * sin(SQRT_5 * rainTime))); + float value = 1. - fract(wobble(rainTime)); // value = 1. - fract(rainTime); // TODO: loop return log(value * 1.25) * 3.; } @@ -79,7 +83,7 @@ float applySunShowerBrightness(float brightness, vec2 screenPos) { float applyThunderBrightness(float brightness, float simTime, vec2 screenPos) { simTime *= 0.5; - float thunder = 1. - fract((simTime + 0.3 * sin(SQRT_2 * simTime) + 0.2 * sin(SQRT_5 * simTime))); + float thunder = 1. - fract(wobble(simTime)); // thunder = 1. - fract(simTime + 0.3); // TODO: loop thunder = log(thunder * 1.5) * 4.; @@ -93,7 +97,7 @@ float applyRippleEffect(float effect, float simTime, vec2 screenPos) { return effect; } - float rippleTime = (simTime * 0.5 + 0.2 * sin(simTime)) * rippleSpeed + 1.; + float rippleTime = (simTime * 0.5 + sin(simTime) * 0.2) * rippleSpeed + 1.; // TODO: clarify // rippleTime = (simTime * 0.5) * rippleSpeed + 1.; // TODO: loop vec2 offset = randomVec2(vec2(floor(rippleTime), 0.)) - 0.5;