X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fblitblur.fs;h=860602281395bd57df0aacc669df7d6d28d0e518;hb=f7db507815e2822d971031c30f25e02b45e9c914;hp=eac828e5e03b700127611dac7160d1235cbd5f00;hpb=75703291fbf045008a3b1ebb20fc46a2617b6b3b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/blitblur.fs b/shaders/blitblur.fs index eac828e..8606022 100644 --- a/shaders/blitblur.fs +++ b/shaders/blitblur.fs @@ -1,5 +1,8 @@ out vec4 FragColor; uniform sampler2D uTexMain; +uniform sampler2D uTexMotion; +uniform float uBlurStrength; +uniform float uBlurExponent; in vec2 aUv; @@ -12,10 +15,16 @@ vec2 rand_hash22( vec2 p ) void main() { - vec2 voffset = rand_hash22( aUv ); + vec2 vcenter = (aUv-vec2(0.5))*vec2(2.0); + vec2 vrand = rand_hash22( aUv ) * 2.0 - vec2(1.0); + vec2 vrand1 = rand_hash22( vrand ) * 2.0 - vec2(1.0); - float bamt = abs(aUv.x-0.5)*2.0; - bamt = pow(bamt,4.0)*0.05; + vec2 vdir = texture( uTexMotion, aUv ).xy * uBlurStrength; - FragColor = texture( uTexMain, aUv + voffset*bamt ); + vec4 vcolour0 = texture( uTexMain, aUv + vdir*vrand.x ); + vec4 vcolour1 = texture( uTexMain, aUv + vdir*vrand.y ); + vec4 vcolour2 = texture( uTexMain, aUv + vdir*vrand1.x ); + vec4 vcolour3 = texture( uTexMain, aUv + vdir*vrand1.y ); + + FragColor = ( vcolour0 + vcolour1 + vcolour2 + vcolour3 ) * 0.25; }