- Home /
How to create an imageEffect that blurs each pixel differently?
Hello!
I would like to write a imageEffect shader that blurs an image - but the amount of blur should not be the same at every pixel. For example, it should not blur the image on the bottom, but blur it strong on on the top, and gradually interpolate the blur amount over the image. I analysed the existing blur shader, and there Graphics.BlitMultiTap is used to make multiple texture-lookups to achieve the blurring. But I don't see how the offsets can be varied at each processed pixel?
For example, I want the effect to do something like:
ofst = V * 0.1f; // have large offset at top of rendered quad, and zero offset at bottom
vec2 uv1 = vec2(U-ofst, V-ofst);
vec2 uv2 = vec2(U-ofst, V+ofst);
vec2 uv3 = vec2(U+ofst, V-ofst);
vec2 uv4 = vec2(U+ofst, V+ofst);
destPixelCol = 0.25f*(texture(sourceTexture, uv1) +
texture(sourceTexture, uv2) +
texture(sourceTexture, uv3) +
texture(sourceTexture, uv4));
How would I create such an effect? I have experience with GLSL, but i'm completely new to shaderlab.
thanks
Answer by dvdkong · May 16, 2014 at 01:34 PM
just use a look up texture, where darker pixels mean less blur, and lighter more