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 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.
- Create an empty destination cubemap.
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.
- Apply your favorite blur algorithm.
- Copy F to the destination cubemap.
- Repeat 2-4 for each face.
精彩评论