Jump to content

Recommended Posts

Posted

precision mediump float;
uniform sampler2D vTex;
varying vec2 vCoord;
const float step_w = 0.0015625;
const float step_h = 0.0027778;
vec3 blur()
{
   float y = vCoord.t < 0.4 ? vCoord.t : 1.0 - vCoord.t;
   float dist = 8.0 - 20.0 * y;

   vec3 acc = vec3(0.0, 0.0, 0.0);
   for (float y=-2.0; y<=2.0; ++y)
   {
    for (float x=-2.0; x<=2.0; ++x)
    {
	    acc += texture2D(vTex, vec2(vCoord.x + dist * x * step_w, vCoord.y + 0.5 * dist * y * step_h)).bgr;
    }
   }
   return acc / 25.0;
}
void main(void)
{
   vec3 col;
   if (vCoord.t >= 0.4 && vCoord.t <= 0.6)
    col = texture2D(vTex, vCoord).bgr;
   else
    col = blur();
   gl_FragColor.a = 1.0;
   gl_FragColor.rgb = col;
}

The code above is faking tilt shift its from this website: http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html

 

and this topic should help also.

http://stackoverflow.com/questions/4579020/how-do-i-use-a-glsl-shader-to-apply-a-radial-blur-to-an-entire-scene

  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...