6

Any ideas how to do it? Now i have dynamically generated cubemap, which i use as a reflection texture on torus.

Blurring every side separately won't do the trick, right? Because of pixels near the border, which won't get blur impact from their neighbours.

Maybe i should make another FBO, bind it, "unroll" cubemap on the screen, apply basic blur shader and then separate that blurred texture into 6 sides? Not sure how to do the "separate" part.

spacevillain
  • 1,336
  • 1
  • 14
  • 25

1 Answers1

6

Blurring a cubemap? That's pretty hard.

To do a mathematically correct Gaussian blur, you need to transform it to the frequency domain (spherical harmonics), apply a low-pass filter there, and then do the inverse transform. That's not a simple task.

If an approximation is enough, do the following.

  1. Create an empty destination cubemap.
  2. For each face F of your cube, render the face F and the neighboring pixels from the other 4 faces like this:

     ___________
    |\         /|
    | \       / |
    |  \-----/  |
    |  |     |  |
    |  |  F  |  |
    |  |     |  |
    |  /-----\  |
    | /       \ |
    |/_________\|
    

    The amount of neighboring pixels depends on blur radius.

  3. Apply your favorite blur algorithm.
  4. Copy F to the destination cubemap.
  5. Repeat 2-4 for each face.
Yakov Galka
  • 70,775
  • 16
  • 139
  • 220
  • 1
    Wow... understand that this might be necessary for "spherically correct" result, but is it really distinguishable from a simple gaussian blur on the "flat" cube map with a special case for calculating neighbouring pixels on the seams? – Kos Dec 04 '10 at 13:30
  • 1
    @Kos: The second suggestion is *not* spherically correct, it will appear blured more in the middle of the faces. Also this is the simplest way to handle neighboring pixels on the seams. – Yakov Galka Dec 04 '10 at 14:00
  • I understand that it's not correct, my question is "is it *perceivably* incorrect". For example the Phong-Blinn specular lighting model is not "correct", but still looks good. – Kos Dec 04 '10 at 14:05
  • You could use an adaptive blurring kernel, which gets larger towards the corners. Or even better, make the blurring kernel a projection of the gaussian distribution disk of the currently processed pixel on the cubemap faces. – datenwolf Dec 04 '10 at 19:06
  • @datenwolf Why don't put this into a answer? – Felix K. Sep 08 '14 at 12:47
  • 1
    @FelixK.: Because my personal standards would require to actually provide an implementation then. And depending on the size of the cubemap a FFT based approach might be even more performant (there are CUDA and OpenCL implementations for FFT which could be put to use). – datenwolf Sep 08 '14 at 13:06