PDA

View Full Version : proper cube map texture mapping



remdul
06-04-2014, 07:11 AM
I've always found it annoying that the cube map texture coordinate arrangement works different than everything else in GL. This was done to match DirectX and RenderMan when it was first introduced. But it requires hacks in texture loaders to swap faces, and unnecessary/ugly code in shaders to flip vector axis. From personal experience, processing of pre-rendered cubemaps is still a hassle anyway (IBL and such), rendering moot the intention of the chosen arrangement to alleviate complexity.

See also:
http://stackoverflow.com/questions/11685608/convention-of-faces-in-opengl-cubemapping
http://www.nvidia.com/object/cube_map_ogl_tutorial.html (skip to "Mapping Texture Coordinates to...")

It seems like an appropriate time to have this fixed. An extension should be trivial to implement and could be widely supported.

I'll leave the API to your imagination. I would suggest, however, not to copy the mistake from GL_TEXTURE_CUBE_MAP_SEAMLESS to make it a global state; it should be part of the texture object (e.g. set with glTexParameter).

mhagain
06-04-2014, 03:18 PM
There's already an API for this: it's called a texture matrix.