14
\$\begingroup\$

So i came across this site and you can see these lines on the first and second paragraph:

For a crude but easy effect, draw the bright portions of the scene (eg, light sources) into an FBO, then downsample it using GL_LINEAR minification several times. For the final render, simply combine the original scene with the downsampled FBO's.

In the following example, the original scene is 128 x 128 and is downsampled 3 times. This requires 4 framebuffer objects. The original scene is shown in the upper-left and the final rendering in the upper-right.

Is there any reason i should downsample multiple times (128 -> 64 -> 32 -> 16) rather than downsample it once (128 -> 16)?

If you scroll down more, they even downsample it like 9 times. (128 -> ... -> 16 -> 128 -> ... -> 16 -> and so on). Why not do it like (128 -> 16 -> 128 -> 16 -> and so on)?

\$\endgroup\$
1
  • \$\begingroup\$ Truly absurd approach. Just blur the buffer and downsample with GL_NEAREST. \$\endgroup\$ May 4, 2016 at 18:50

1 Answer 1

23
\$\begingroup\$

There are two main benefits:

First, if you downsample by more than a factor of two, some pixels in the original image will have no impact on the result image. Using GL_LINEAR, each destination pixel will only sample from at most 4 pixels from the source image; the other pixels simply get discarded. By downsampling by a factor of two, you ensure that each pixel from the source image has kept an equal effect on the next layer down.

Second, the algorithms discussed on that site require every one of the framebuffer objects; they're actually all required, even if there wasn't a good reason for downsampling in this way. You can't skip the 64x64 or the 32x32 images, because those images are used as part of constructing the gaussian-blurred result image.

Finally, if you read the article you'll see that it isn't advocating downsampling images 9 times; it downsamples just three times, and then does several operations on those downsampled images. The images you're looking at are just showing the state of those same 3 downsampled images after each step of the process, not showing separate downsampling events.

\$\endgroup\$
2
  • \$\begingroup\$ Ah, this makes so much sense to me now. Thank you. \$\endgroup\$
    – Greffin28
    May 4, 2016 at 5:17
  • 1
    \$\begingroup\$ (Incidentally, the bloom effect I use in my own games is based upon the method described on the linked page. Personally, I downsample 5 times rather than 3, since I start from a much larger initial image but still want a nice, wide blur.) \$\endgroup\$ May 4, 2016 at 12:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .