Simplifying rainPass.compute's weirder operations.

This commit is contained in:
Rezmason
2021-10-23 01:12:31 -07:00
parent 2265e3c937
commit cf5f8c2113
3 changed files with 16 additions and 15 deletions

View File

@@ -1,13 +1,10 @@
TODO: TODO:
Improve forkability Write an explanation of the rain pass (and include images)
Refactor rainPass.compute's sin(sqrt(5)) stuff, there must be a clearer expression Compute
Volumetric quads
Write an explanation of the rain pass (and include images) Fullscreen quad and spacial mapping
Compute MSDFs
Volumetric quads
Fullscreen quad and spacial mapping
MSDFs
Resurrection Resurrection
Modified glyph order? Modified glyph order?

View File

@@ -72,7 +72,7 @@ const versions = {
bloomStrength: 0.75, bloomStrength: 0.75,
highPassThreshold: 0.0, highPassThreshold: 0.0,
cycleSpeed: 0.2, cycleSpeed: 0.2,
cycleFrameSkip: 6, cycleFrameSkip: 8,
cycleStyleName: "cycleRandomly", cycleStyleName: "cycleRandomly",
cursorEffectThreshold: 0.64, cursorEffectThreshold: 0.64,
brightnessOverride: 0.22, brightnessOverride: 0.22,

View File

@@ -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))); 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 // Core functions
// Rain time is the shader's key underlying concept. // 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. // It's why glyphs that share a column are lit simultaneously, and are brighter toward the bottom.
float getRainTime(float simTime, vec2 glyphPos) { float getRainTime(float simTime, vec2 glyphPos) {
float columnTimeOffset = randomFloat(vec2(glyphPos.x, 0.)); float columnTimeOffset = randomFloat(vec2(glyphPos.x, 0.)) * 1000.;
float columnSpeedOffset = randomFloat(vec2(glyphPos.x + 0.1, 0.)); float columnSpeedOffset = randomFloat(vec2(glyphPos.x + 0.1, 0.)) * 0.5 + 0.5;
// columnSpeedOffset = 0.; // TODO: loop // 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; return (glyphPos.y * 0.01 + columnTime) / raindropLength;
} }
float getBrightness(float rainTime) { 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 // value = 1. - fract(rainTime); // TODO: loop
return log(value * 1.25) * 3.; return log(value * 1.25) * 3.;
} }
@@ -79,7 +83,7 @@ float applySunShowerBrightness(float brightness, vec2 screenPos) {
float applyThunderBrightness(float brightness, float simTime, vec2 screenPos) { float applyThunderBrightness(float brightness, float simTime, vec2 screenPos) {
simTime *= 0.5; 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 = 1. - fract(simTime + 0.3); // TODO: loop
thunder = log(thunder * 1.5) * 4.; thunder = log(thunder * 1.5) * 4.;
@@ -93,7 +97,7 @@ float applyRippleEffect(float effect, float simTime, vec2 screenPos) {
return effect; 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 // rippleTime = (simTime * 0.5) * rippleSpeed + 1.; // TODO: loop
vec2 offset = randomVec2(vec2(floor(rippleTime), 0.)) - 0.5; vec2 offset = randomVec2(vec2(floor(rippleTime), 0.)) - 0.5;