View Full Version : Cubemap orientation
Weird problem. When i upload a 2D texture, and i render a Quad with Texcoord (0|0) bottom left and (1|1) top right, everything is fine and the texture appears as in any image editing program.
Now i use the exact same code to load a cubemap, but when using (-1|-1|-1) for bottom left front and (1|1|-1) for top right front, i can see the front cubemap face, but the texture is rotated 180 degree.
I checked the documentation, but it seems, as if all i do should be correct.
However, since i really use the same code, i am quite sure i don't accidently mix something up.
Could it be, that cubemap faces are stored differenctly than 2D textures and therefore i need to rotate them?
They are all reversed I guess: here is a portion of my code:
gluLookAt (0,0,0, 1,0,0, 0,-1,0);
glCopyTexSubImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0,0,0,0,0, cms,cms);
I would confirm this. I guess this is because of the principle of reflections: just imagine a little hole in between the face of the object that will receive the reflection and the part-side of the world that will be reflected on it: all the rays will be inverted. This is also the principle of the camera: when you look in a box with a little whole, everything is inverted, this is also the principle of our eyes.
But I don't know if this is because of this reflections are done this way under GL.
Ah, that makes actually sense!
I was wondering, why cubemaps should be stored differently than other textures, but of course, when cubemaps were introduced they were mostly used for environmental reflections with automatic texture-coordinate generation. Then it makes sense to avoid extra calculations by storing the data differently.
Mystery solved, thanks guys.
Is it possible that top and bottom are swapped too?
What do you mean ? that the bottom is at the top and 'vice-versa' ? No.
04-12-2006, 03:39 PM
the cubemap axes are in that table in spec on page 128. one thing that might trip you up (did me) is that those directions can be viewed from either inside or outside the cube. of course if you flatten the cube out, things looks a bit different too.
if you're outside the cube standing on the plane y=0, the texture origin is in the top left of each side quad, and the s and t axes go right and down. for the top face, look down the -y axis, for the bottom, look down the +y axis. the origin is still in the top left, s and t going right and down.
however you want to look at it.
Problem is, that my laptop is broke at the moment and i can't check where the error might be in my code.
However, i don't understand where there should be a difference, if i imagine to stand inside or outside the cube.
When working with cubemaps i always imagine to be inside the cube. Now when i look up (along the +Y axis), i should see the TOP face. But last time i checked, i saw the BOTTOM face. I actually "solved" it, for now, by uploading the top face as NEGATIVE_Y instead of POSITIVE_Y.
No, looking at the top is POSITIVE_Y for me.
04-13-2006, 09:34 AM
Jan, the difference is in what's "right" and "down" for the s and t axes. Again, the s and t axes point right and down, respectively, and the origin is always in the top left, if you're standing outside the cube. It might be easier to remember that way.
Perhaps it's just me.
09-20-2010, 02:37 PM
This does not work for me. Looking in the positive x direction with top at -y gives the wrong result... not sure why though.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.