5
$\begingroup$

In image editing software, you often have the ability to do a directional blur where you can choose and angle and a magnitude of a blur.

How does this actually work in practice with Gaussian blurring?

I could see possibly doing something like making the blur go across the axis specified by the angle and use some sort of texture sampling to find the appropriate sample (bilinear or bicubic sampling), but that seems like it probably isn't correct.

How does directional blurring usually work?

I would say this is in fact motion blur, but I'm asking specifically about the blurring portion, not the whole set up for motion blur within a renderer.

For instance before and after:

enter image description here enter image description here
(source: gimp.org)

$\endgroup$
2
  • $\begingroup$ Is the directional blurring you are referring to motion blur? $\endgroup$ Commented Aug 15, 2015 at 20:14
  • $\begingroup$ An example before and after image would help confirm what type of blur is being asked about. $\endgroup$ Commented Aug 15, 2015 at 20:14

1 Answer 1

5
$\begingroup$

If I understand your question, you are asking how to actually perform said directional blur in code? A Gaussian blur is typically done by sampling your image in all directions around your current point (or if in 2 passes, one vertical and one horizontal which equates to the same thing), with a specific set of weights for the falloff.

For a directional blur you just need to change the shape of your kernel to "not be round", for lack of better words.

Say you wanted to smear the image to the left only, you could just accumulate samples (with whatever weights you want) with

currentPixelUV.xy + float2( -1.f * someOffsetScale, 0.f) * invScreenRes.xy * currentIteration;

Bilinear texture filtering will be required for this to work when your resulting uvs are not hitting pixel centers.

The magnitude of the blur is controlled by how far you sample from your original pixel.

$\endgroup$
1
  • $\begingroup$ BTW just to help future folk. Bicubic interpolation will give higher quality results than bilinear when taking samples, at a higher computational cost. $\endgroup$
    – Alan Wolfe
    Commented Aug 16, 2015 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.