Bicubic cubemap filtering

Hi all,

As the title suggest, I try to do bicubically filtered texture accesses in a cubemap by manually computing the weights and required texel reads in a shader. It works quite well except for the edges of the cube where some seams occur. I have not yet managed to get rid of these seams.

So far, google gave me no hint how to do it.
Has anyone here ever done something similar or knows where I can find some information about this topic?

Bicubic interpolation in 3D? Wow, that is 4x4x4=64 pixels need to be taken into account in order to extract an interpolated value!
What behavior do you need at the edges? If it is wrap-around then you take a modulo of the coordinate skipping the integer part so at the right edge the pixels of the left edge will be referenced. If you want to clamp to edge without artifacts at the edges, then you constrain yourself to the internal area of the image (±2 pixels from borders). If you are OK with artifacts on edges, then at least clamp the coordinates to prevent out-of-bounds pixel references.

Well it’s not that bad. I want to interpolate a cubemap, not a 3d texture, so it is 16 texture accesses, not 64. I am doing a virtual globe rendering where a cubemap stores the coarse detail and the rest is added by procedural noise. The interpolation has to be perfect at the edges because at the scale of a virtual globe every discontinuity will be visible as a crack in the landscape. Bilinear interpolation is not sufficient because the terrain will not be as smooth as i would like it to be, so I want to use bicubic. Everything works great except for the edges (and the corners, where the discontinuities are even worse). The key is to get the correct neighbour pixels at the edges and compute the weights. Here, i am stuck at the moment.

The 2-pixel-border sounds like a good idea, but it really only shifts my problems elsewhere. I already tried that, but gave up on it.

Oh, sorry, it is a cubemap, my bad. :slight_smile:
I would humbly recommend to fetch the texels directly - this way you will be sure which texel is referenced so you could handle all border conditions the way you like. It will be computationally expensive and complicated, though.
However, there are no texelFetch function in glsl for cubemaps. You may want to create a 2D array texture view for your cubemap texture in order to access each individual face as a layer of that texture.
As an alternative, why not using clipmaps?

Thanks for your help!
Now the interpolation works just fine! After trying to calculate the correct indices for every adjacent face combination I realized that texel duplication at the borders is much easier to do at practically no memory cost (2 texels at each edge is nothing if the texture itself is 2048² texels).

Clipmaps would be an alternative but I never used them before so I have no experience.