Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using libGDX for an android game; as far as I can tell, it doesn't have an API for blurring.

Reading on Wikipedia, it seems like blur is formed by setting each pixels RGB values to the average of all adjacent values. Which doesn't seem easily possible in libGDX -- setting pixel data.

So my question is simple:

Is it possible to fake (a decent) blur using only images?

I can potentially overlay multiple (in number, transparency, type) images; but can I create a convincing blur like this?

I'm tempted to say "no," but maybe someone else has achieved something similar. For clarity, I want a set of 1+ generic images I can render on top of ANY image to generate a blur-like effect.

share|improve this question
good question! I've thought of the same thing, myself! – Daniel Pendergast Oct 20 '11 at 1:21
@DantheMan on which platform? – ashes999 Oct 20 '11 at 1:40
Unity3d or the CG shading language. – Daniel Pendergast Oct 20 '11 at 1:56
You suggest overlaying transparent images over one another. If you slightly offset them, you're going to be averaging the pixels, achieving blur – Jeff Oct 20 '11 at 2:30
@ashes999, if you're looking for a "magic image" that can be overlaid on things to make them appear blurry, that doesn't exist. Alpha-blending (overlaying) isn't remotely the same thing as blurring, sorry. – Nathan Reed Oct 20 '11 at 2:51

If you're able to additively blend images and multiply them by a constant while doing so, then you can do a blur. Instead of averaging the pixels in a neighborhood, you'd average several copies of the image displaced by a small number of pixels from each other. Or more generally, you could do a Gaussian blur or whatever kind of blur, by controlling the weights - that is, multiplying each displaced copy of the image by a constant as it's being added onto the rest.

Algorithmically, it would look something like this:

clear output_image to 0
foreach offset, weight in filter_kernel:
    output_image += input_image * weight, shifted by offset

You'd use the same offsets and weights as in the standard way of doing a blur. There are plenty of articles on the Web on how to generate the weights for a Gaussian blur, for instance.

share|improve this answer
+1 nice answer. In my case, I don't have additive ability. – ashes999 Oct 20 '11 at 2:57

Blurring can be an expensive operation, perhaps a different approach could work, e.g.:

  1. Store multiple copies of the image blurred in several different directions (e.g. multiples of 45 degrees), then display the closest matching image at runtime. This will offer the highest performance, at the cost of memory usage.
  2. Scale the image down and then back to full-size with anti-aliasing/smoothing. Often this can be done with graphics hardware with very little performance impact.
share|improve this answer
It won't work, because it has to be dynamic, i.e. I can't know the exact setup of the screen ahead of time. – ashes999 Oct 20 '11 at 15:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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