PDA

View Full Version : cube mapping



therealremi
03-06-2007, 05:15 AM
I've read the old Nvidia's article about cube mapping but I would need a more complete and recent example of using it. Maybe you have a link?

I also have a question: how do you use GL_TEXTURE_CUBE_MAP_ARB and GL_TEXTURE_2D in the same program? Is it so that at once only one of the two texture targets can be active? What if I want to accsess both 2D texture and cubemap in the same fragment program? Is this possible? I remember somebody saying that this is not possible but I also remember seeing calls to both tex2D() and texCUBE() in one fragment program in the book "the Cg tutorial".

And one more: do I have to generate some texture coordinates in OpenGL in order to access the cube map using texCUBE() in a shader? I just want the cube map color given a 3D vector (coordinates), nothing else.

k_szczech
03-06-2007, 06:54 AM
I've read the old Nvidia's article about cube mapping but I would need a more complete and recent example of using itIt is complete and if something is complete then there's nothing more complete :)
Also, you don't need anything more recent, since cubemaps didn't change since then. Shaders were added and they allow to use cubemaps, but that's it.

You can use multiple textures in shader - just bind each one to different texture unit:

do I have to generate some texture coordinates in OpenGL in order to access the cube map using texCUBE() in a shader?You have to specify cordinates to access any texture - why would cubemaps be different?
You can use glTexGen functionality to generate coordinates, but if you use vertex shader you have to do that by yourself, since vertex shader replaces fixed functionality (that means glTexGen, too).

therealremi
03-06-2007, 10:15 AM
k_szczech, I got it working. The thing is, I have to call glEnable(GL_TEXTURE_CUBE_MAP_ARB) before loading the cube map and glDisable(GL_TEXTURE_CUBE_MAP_ARB) afterwards, whereas 2D texturing can be enabled the whole time. And this is the part I don't fully understand.

Btw, are you involved in some project currently? You definitely have the knowledge to do some serious game programming.

Zengar
03-06-2007, 10:39 AM
You don't need to glEnable(GL_TEXTURE_CUBE_MAP_ARB) before loading a cube map, the enable caps are used to select the texture target that will be used for rendering. Maybe you misunderstood something.

k_szczech
03-06-2007, 11:42 AM
Btw, are you involved in some project currently? You definitely have the knowledge to do some serious game programming.See my profile.
Actually I'm a bit overworked recently because of my full time job. We're trying to squeeze a 2-year project in 6 months. It's an overkill.

Luckily I still have enough good will to work on my game, my framework and write a few posts in this forum :)