开发者

Blurring a cubemap

开发者 https://www.devze.com 2023-01-28 03:21 出处:网络
Any ideas how to do it? Now i have dynamically generated cubemap, which i use as a reflection texture on torus.

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 shoul开发者_运维技巧d 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.


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号