I'm trying to map quadsphere with COBE spherical cube (CSC) projection in OpenGL (wanna map planets). I managed to create a 2D texture and it works well except seams at edges.

Then I learned that there is a cubemap in OpenGL. It has some advantages: It automatically generates seamless mipmap and it requires less memory (I was using 4*size width 3*size height texture where a half is just wasted like this: https://camo.githubusercontent.com/b017f71b03e6180dc75ff34f017d45f32e9db817/68747470733a2f2f7261772e6769746875622e636f6d2f6369782f517561645370686572652f6d61737465722f6578616d706c65732f677269642e706e67)

The problem with using cubemap is that CSC is not gnomonic projection. So I can't just use vertex point as 3D texture coordinates. I have to calculate 3D texture coordinates from uv coordinates and the face. Then OpenGL recalculate it to uv coordinate and the face. I guess that slows down the rendering compared to simple 2D texture.

The problem with using 2D texture is that it is not easy to make texture seamless. And it takes more memory if I use one image file for whole texture. I think I could pre-generate mipmaps sampling adjacent faces and add 1px padding and modify uv coordinates slightly (like this? https://gamedev.stackexchange.com/a/49585/74052). But it sounds complicated and I have to pre-generate all mipmaps, and textures might no be in size of power of 2 and I might have another problem with that.

I have no idea which way to go.

  1. When using cubemap, is there a way to specify uv coordinates and face directly, and not specify 3D texture coordinates (direction)?

  2. Is there a way to set 2D texture wrap mode to something like CLAMP_TO_EDGE_OF_OTHER_TEXTURE to make it seamless at edges?

  3. Is there other way to make a 2D cube texture seamless?

  4. Any other suggestion to deal with this problem?

Thanks in advance!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.