diff --git a/js/rainPass.js b/js/rainPass.js index 6e0a3cf..69e6c21 100644 --- a/js/rainPass.js +++ b/js/rainPass.js @@ -135,7 +135,7 @@ export default (regl, config) => { uniforms: { ...renderUniforms, - lastState: doubleBuffer.front, + state: doubleBuffer.front, glyphTex: msdf.texture, camera: regl.prop("camera"), diff --git a/shaders/rainPass.frag b/shaders/rainPass.frag index a0f1a82..a40b2c9 100644 --- a/shaders/rainPass.frag +++ b/shaders/rainPass.frag @@ -4,7 +4,7 @@ #endif precision lowp float; -uniform sampler2D lastState; +uniform sampler2D state; uniform float numColumns, numRows; uniform sampler2D glyphTex; uniform float glyphHeightToWidth, glyphSequenceLength, glyphTextureColumns, glyphEdgeCrop; @@ -42,7 +42,7 @@ void main() { uv.y -= 0.5; float radius = length(uv); float angle = atan(uv.y, uv.x) / (2. * PI) + 0.5; - uv = vec2(angle * 4. - 0.5, 1.5 - pow(radius, 0.5) * 1.5); + uv = vec2(fract(angle * 4. - 0.5), 1.5 * (1. - sqrt(radius))); } else { // Applies the slant and scales space so the viewport is fully covered uv = vec2( @@ -54,7 +54,7 @@ void main() { } // Unpack the values from the data texture - vec4 glyph = volumetric ? vGlyph : texture2D(lastState, uv); + vec4 glyph = volumetric ? vGlyph : texture2D(state, uv); float brightness = glyph.r; float symbolIndex = getSymbolIndex(glyph.g); float quadDepth = glyph.b; diff --git a/shaders/rainPass.vert b/shaders/rainPass.vert index 636eee9..09d8758 100644 --- a/shaders/rainPass.vert +++ b/shaders/rainPass.vert @@ -1,7 +1,7 @@ #define PI 3.14159265359 precision lowp float; attribute vec2 aPosition, aCorner; -uniform sampler2D lastState; +uniform sampler2D state; uniform float density; uniform vec2 quadSize; uniform float glyphHeightToWidth, glyphVerticalSpacing; @@ -24,7 +24,7 @@ highp float rand( const in vec2 uv ) { void main() { vUV = (aPosition + aCorner) * quadSize; - vGlyph = texture2D(lastState, aPosition * quadSize); + vGlyph = texture2D(state, aPosition * quadSize); // Calculate the world space position float quadDepth = 0.0;