Created
July 23, 2012 11:36
-
-
Save danbri/3163175 to your computer and use it in GitHub Desktop.
radial blur, based on bkcore.com code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// radial blur from touch pos, from http://bkcore.com/blog/3d/webgl-three-js-volumetric-light-godrays.html | |
vec3 draw() { | |
vec2 vUv = p; | |
float fX=t1.x, fY=t1.y, illuminationDecay = 1.0, | |
fExposure = 0.2, fDecay = 0.93, | |
fDensity = .3, fWeight = 0.4, fClamp = 1.0; | |
const int iSamples = 8; | |
vec2 delta = vec2(vUv-vec2(fX,fY))/float(iSamples)*fDensity, coord = vUv; | |
vec4 FragColor = vec4(0.0); | |
for(int i=0; i < iSamples ; i++) { | |
coord -= delta; | |
vec4 texel = vec4( cam(coord), 0.0); | |
texel *= illuminationDecay * fWeight; | |
FragColor += texel; | |
illuminationDecay *= fDecay; | |
} | |
FragColor *= fExposure; | |
FragColor = clamp(FragColor, 0.0, fClamp); | |
return(vec3(FragColor)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment