I am trying to understand the reasoning behind the image orientation for cubemap images displayed on a skybox. I found nothing helpful, mostly a lot of misinformation, in an internet-wide search. I found two very old posts in this forum which are on topic:
but they aren’t helpful as people keep talking about flipping images without being specific about the orientation. There are links in both to a .ppt from @cass said to explain the reasoning but the link returns error 404. There is also a link to an old opengl.org forum post, also seemingly by @cass, which likewise returns 404.
So could someone please provide exact information as to the requirements and reasoning behind it.
In the following descriptions my starting point is photographs of the scene matching the ground truth.
What I have found is that, on OpenGL, images with the default bottom-up orientation have to be flipped vertically and all images have to be flipped horizontally - something most people never seem to have noticed. Actually no flipping is necessary, you can just apply a scale of -1, -1, 1 to the uvw coordinates being passed in to the cube sampler.
On Vulkan images with a top-down orientation need to be flipped or a -1 scale applied to the y coord. If you try with bottom-up oriented images you don’t need y*-1 for the images to have correct vertical orientation but the sky and ground will be swapped. You have to swap the posy and negy images in the cubemap for this to work. A -1 scale needs to be applied to the x coord, as with OpenGL, regardless of the image’s y orientation.
All this is in line with the face selection table and equations in the OpenGL & Vulkan specs. But I am completely failing to understand why it was designed this way.
All the OpenGL samples I have looked at in the wild load the cubemap from individual .jpg or .png files. Since these formats have a top down orientation the samples just work. Except for the left-right issue.
I have found Vulkan samples using ktx files with posy and negy swapped whose images have a bottom up orientation (mislabelled as having top down) so they seem to just work without any scaling of the uvw coords. Except for the left-right issue.
None of the samples or tutorials I’ve found talk about the need for images to be oriented differently than when used in an ordinary 2D texture.
What I am really seeking is a way to load the exact same cubemap texture from a .ktx or .ktx2 file into either OpenGL or Vulkan, so far without success. How can I achieve this. I tried setting up a RH coord system in Vulkan and loading an OpenGL cubemap but, of course, cubemap face selection is unaffected by the viewport transform so +ve y will always select the posy face which in an OpenGL cubemap is the sky but in Vulkan should be the ground.