From d85594a46c6dc4e6e8dfa02d05bbef5b43757938 Mon Sep 17 00:00:00 2001 From: Rezmason Date: Fri, 30 Sep 2022 00:11:22 -0700 Subject: [PATCH] Vertically offsetting glyph columns by a random fraction of the height of a glyph when the volumetric mode is on, to prevent odd visual alignments --- shaders/glsl/rainPass.vert.glsl | 3 +++ shaders/wgsl/rainPass.wgsl | 3 +++ 2 files changed, 6 insertions(+) diff --git a/shaders/glsl/rainPass.vert.glsl b/shaders/glsl/rainPass.vert.glsl index e11d5d8..42b40eb 100644 --- a/shaders/glsl/rainPass.vert.glsl +++ b/shaders/glsl/rainPass.vert.glsl @@ -34,6 +34,9 @@ void main() { vDepth = quadDepth; } vec2 position = (aPosition * vec2(1., glyphVerticalSpacing) + aCorner * vec2(density, 1.)) * quadSize; + if (volumetric) { + position.y += rand(vec2(aPosition.x, 1.)) * quadSize.y; + } vec4 pos = vec4((position - 0.5) * 2.0, quadDepth, 1.0); // Convert the world space position to screen space diff --git a/shaders/wgsl/rainPass.wgsl b/shaders/wgsl/rainPass.wgsl index 1db791f..2ff58b7 100644 --- a/shaders/wgsl/rainPass.wgsl +++ b/shaders/wgsl/rainPass.wgsl @@ -388,6 +388,9 @@ fn computeEffect (simTime : f32, isFirstFrame : bool, glyphPos : vec2, scre // Calculate the vertex's world space position var worldPosition = quadPosition * vec2(1.0, config.glyphVerticalSpacing); worldPosition += quadCorner * vec2(config.density, 1.0); + if (volumetric) { + worldPosition.y += randomFloat(vec2(quadPosition.x, 1.0)); + } worldPosition /= quadGridSize; worldPosition = (worldPosition - 0.5) * 2.0;