PDA

View Full Version : Cube Mapping and Texture Objects



dalangalma
02-06-2004, 09:40 AM
I'm trying to use cube mapping for reflective surfaces. I'm already drawing a skybox with 6 textures mapped to a cube, so I thought it would be easy enough to just glBindTexture(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, myTexture), etc, for all the different faces, since they've already been loaded. I'm using GLUX for loading extensions. However, when I bind the 6 textures this way, nothing happens. The GL_REFLECTION texture generation is working, but the textures aren't. Do I need to load them again using glTexture2D? Shouldn't I be able to share these textures?

M/\dm/\n
02-06-2004, 10:43 PM
glTexSubImage2D + GENERATE_MIPPMAP_SGIS

dalangalma
02-07-2004, 07:20 PM
I'm sorry, I'm not sure what that means.

Here's what I understand:

glTexSubImage2D: Allows me to load a new texture over part of an old texture.

GENERATE_MIPMAP_SGIS: Allows for automatic mipmap generation.

How do I put those together to allow six already-loaded 2D textures to do double-duty as a cube map? It's not clear to me from your response.

M/\dm/\n
02-08-2004, 12:02 AM
Whoups, didn't read your post as carefully as I should have http://www.opengl.org/discussion_boards/ubb/frown.gif
The problem is that cubemap takes place over 1D/2D texturing ops.
If you want to share textures on one obj you have to resort to 2pass rendering or fragment program.

2 paas tech:
bind cubemap
draw stuff
unbind cubemap
glDepthFunc(GL_EQUAL);
glEnable(GL_BLEND);
glColor(r,g,b,0.x);
enable 2D tex
drawstuff
glDepthFunc(GL_LEQUAL);

dalangalma
02-08-2004, 02:18 AM
Hmm, I'm still not sure that helps me. Let me try to refine my question:

Right now, I am drawing a skybox (a cube with 6 separate textures) so I'm already loading 6 2D textures. What I'd like to do is have objects in my scene reflect that skybox. This means the 6 skybox textures need to become 1 cube map. I'd like to just be able to reuse the textures I've already loaded, as opposed to loading them again with glTexture2D into the cubemap targets. How can I do that?

M/\dm/\n
02-08-2004, 02:23 AM
I doub't you can do that, maybe only with fragment program, but the performance penalty will be A LOT higher than if you have seperate cubemap & 6 2d textures. I myself use 6-2D+cube in my programs.

dalangalma
02-08-2004, 04:55 PM
So, just to be clear, I have to load 6 images into GL, then load those same 6 images again into GL to get it to work as both 2D textures and cubemaps.

M/\dm/\n
02-09-2004, 01:48 AM
UGU http://www.opengl.org/discussion_boards/ubb/biggrin.gif