Showing posts with label Frosted glass. Show all posts
Showing posts with label Frosted glass. Show all posts

Wednesday, June 9, 2010

Frosted glass Pixel Shader

We can get frosted glass effect by shifting pixel location with pseudo-random vector, such as after shift respective pattern emerges. Frosted glass GLSL pixel shader code:




uniform sampler2D tex;

float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(92.,80.))) +
cos(dot(co.xy ,vec2(41.,62.))) * 5.1);
}

void main()
{
vec2 rnd = vec2(rand(gl_TexCoord[0].xy),rand(gl_TexCoord[0].xy));
gl_FragColor = texture2D(tex, gl_TexCoord[0].xy+rnd*0.05);
}




Original image

and processed with frosted glass filter