What's a cube Map

Started by
6 comments, last by Ak37 22 years ago
Almost every site talks about Cube Maps. But I just don''t get the point how this cube map works. All I know is that it uses 6 textures. So how do we calculate the texture coordinate ? I need to no the basic theory about this (because there are so many tuts using this cube map and it makes me confuced).
Help me with my Isometric OpenGL engine.
Advertisement
I also have a question similar to the topic.

What is the difference between environmental cube mapping and env. sphere mapping? Both theory and practically.


CUselessStuff::NiftyQuote();

@mikaelbauer

Super Sportmatchen - A retro multiplayer competitive sports game project!

OK. Imagine a cube with its normals inverted, and apply those 6 textures to the 6 sides. Kind of like a skybox...
The hardwere uses alot of trig functions to map all those textures to a polygon that is cube-maped. Making the pollygon look as it was reflecting from being inside that skybox.

... that probobly sounded confusing

[ my engine ][ my game ][ my email ]
SPAM
Rate me up.
Cubemaps are an extension of sphere maps. The principle is the same: a cubemap is a lookup table for a 3D direction vector. Or differently said: it stores the incident light over all directions around a 3D point in space (quantized over a discrete domain, of course). The difference between cubemaps and spehermaps, is that cubemaps do not have the inherent problems of spheremaps: a singularity and poor resolution at the backside.

Imagine a 3D point floating in space. Now imagine a cube floating around that point, with the point being exactly at the middle of the cube. The size of the cube is not important. Each side of this imaginary cube is one of the 6 specified cubemap textures.

Now, say you have a ray starting at your 3D point and going out into space. It''s direction is defined by (s,t,r). It does not need to be normalized, btw. This ray will intersect the cube at a certain moment, since the cube totally surrounds the point. The hardware will first check on which of the 6 cube sides the intersection took place, and select the appropriate texture. It will then calculate the intersection point on the plane of that side, this yields a 2D (s,t) texcoord, that is used to index this texture. The resulting texel is used as the fragment colour for your initial 3D point (after being filtered, mipmapped, etc).

Cubemaps are useful for anything that needs a 3D light incidence map around a point. That includes reflections, refractions, advanced per pixel lighting (BRDF). It can also be used as a fast per-pixel normalization system for accurate DOT3 bumpmapping.

Hope that clears it up a bit, cubemaps are not that intuitive to understand.

/ Yann
Another difference is with cube-map reflection you can move your camera, but with sphere-map reflection you can''t
Is it required to specify a 3d tex coord to use a cube map.

I still don''t understand how do we do a polygon mapping with this cube map ? If in a normal 2D texture we only need to specify glTexCoord2f before each vertex then how would we implement this in a cube map ?
Help me with my Isometric OpenGL engine.
quote:
Is it required to specify a 3d tex coord to use a cube map.

Yes. You specify a direction vector, so that''s 3 components.

quote:
I still don''t understand how do we do a polygon mapping with this cube map ? If in a normal 2D texture we only need to specify glTexCoord2f before each vertex then how would we implement this in a cube map ?

Specify glTexCoord3f(...) before each vertex coordinate. Or use an automatic texgen function.

Try that: when you render your object, specify the vertex normals as 3D texture coordinates into a cubemap. With a good cubemap, you''ll get an interesting reflection effect.

/ Yann
Thank you. I''ll try that.
Help me with my Isometric OpenGL engine.

This topic is closed to new replies.

Advertisement