openglblurcube

Blurring a cubemap


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.


Solution

  • 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.