Monday, June 7, 2010

Explosion and implosion Pixel Shader

Explosion/Implosion filter can be modeled by shifting pixel outwards/towards the center of image by value which is proportional to pixel distance from the center of image.
Explosion/Implosion pixel shader code in GLSL:

uniform sampler2D tex;

void main()
vec2 cen = vec2(0.5,0.5) - gl_TexCoord[0].xy;
vec2 mcen = - // delete minus for implosion effect
gl_FragColor = texture2D(tex, gl_TexCoord[0].xy+mcen);

By applying this filter to image below

we get such explosion effect

and such implosion effect

No comments:

Post a Comment

Comment will be posted after comment moderation.
Thank you for your appreciation.