From 11bba1020d389a5e3a9ddfe6eb1317118c24b6fb Mon Sep 17 00:00:00 2001 From: Rezmason Date: Mon, 8 Nov 2021 09:29:04 -0800 Subject: [PATCH] Changing my mind a little about how to render the "behind the scenes" version of the effect, in regular and volumetric mode. An isometric perspective would be neat. --- shaders/glsl/rainPass.compute.frag.glsl | 4 ++-- shaders/glsl/rainPass.frag.glsl | 2 +- shaders/glsl/rainPass.vert.glsl | 3 +-- shaders/wgsl/rainPass.wgsl | 8 ++++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/shaders/glsl/rainPass.compute.frag.glsl b/shaders/glsl/rainPass.compute.frag.glsl index d3a3307..405905f 100644 --- a/shaders/glsl/rainPass.compute.frag.glsl +++ b/shaders/glsl/rainPass.compute.frag.glsl @@ -179,9 +179,9 @@ vec4 computeResult(bool isFirstFrame, vec4 previousResult, vec2 glyphPos, vec2 s vec4 result = vec4(brightness, cycle, depth, effect); - // Better use of the blue channel, for demonstrating how the glyph cycle works + // Better use of the alpha channel, for demonstrating how the glyph cycle works if (showComputationTexture) { - result.b = min(1., localCycleSpeed); + result.a = min(1., localCycleSpeed); } return result; diff --git a/shaders/glsl/rainPass.frag.glsl b/shaders/glsl/rainPass.frag.glsl index 52ebe8b..f6b6672 100644 --- a/shaders/glsl/rainPass.frag.glsl +++ b/shaders/glsl/rainPass.frag.glsl @@ -79,7 +79,7 @@ void main() { float alpha = clamp(sigDist/fwidth(sigDist) + 0.5, 0.0, 1.0); if (showComputationTexture) { - gl_FragColor = vec4(glyph.rgb - alpha, 1.0); + gl_FragColor = vec4(glyph.r - alpha, glyph.g * alpha, glyph.a - alpha, 1.0); } else { gl_FragColor = vec4(vChannel * brightness * alpha, 1.0); } diff --git a/shaders/glsl/rainPass.vert.glsl b/shaders/glsl/rainPass.vert.glsl index 09d8758..3a79f22 100644 --- a/shaders/glsl/rainPass.vert.glsl +++ b/shaders/glsl/rainPass.vert.glsl @@ -9,7 +9,6 @@ uniform mat4 camera, transform; uniform vec2 screenSize; uniform float time, animationSpeed, forwardSpeed; uniform bool volumetric; -uniform bool showComputationTexture; uniform float resurrectingCodeRatio; varying vec2 vUV; varying vec3 vChannel; @@ -28,7 +27,7 @@ void main() { // Calculate the world space position float quadDepth = 0.0; - if (volumetric && !showComputationTexture) { + if (volumetric) { quadDepth = fract(vGlyph.b + time * animationSpeed * forwardSpeed); vGlyph.b = quadDepth; } diff --git a/shaders/wgsl/rainPass.wgsl b/shaders/wgsl/rainPass.wgsl index 3d98012..228f63b 100644 --- a/shaders/wgsl/rainPass.wgsl +++ b/shaders/wgsl/rainPass.wgsl @@ -253,9 +253,9 @@ fn computeResult (isFirstFrame : bool, previousResult : vec4, glyphPos : ve var result = vec4(brightness, cycle, depth, effect); - // Better use of the blue channel, for demonstrating how the glyph cycle works + // Better use of the alpha channel, for demonstrating how the glyph cycle works if (bool(config.showComputationTexture)) { - result.b = min(1.0, localCycleSpeed); + result.a = min(1.0, localCycleSpeed); } return result; @@ -311,7 +311,7 @@ fn computeResult (isFirstFrame : bool, previousResult : vec4, glyphPos : ve // Calculate the quad's depth var quadDepth = 0.0; - if (volumetric && !bool(config.showComputationTexture)) { + if (volumetric) { quadDepth = fract(vGlyph.b + time.seconds * config.animationSpeed * config.forwardSpeed); vGlyph.b = quadDepth; } @@ -424,7 +424,7 @@ fn getSymbolUV(glyphCycle : f32) -> vec2 { var output : FragOutput; if (bool(config.showComputationTexture)) { - output.color = vec4(glyph.rgb - alpha, 1.0); + output.color = vec4(glyph.r - alpha, glyph.g * alpha, glyph.a - alpha, 1.0); } else { output.color = vec4(input.channel * brightness * alpha, 1.0); }