#### Archived

This topic is now archived and is closed to further replies.

# What's a cube Map

This topic is 6024 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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).

##### Share on other sites
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();

##### Share on other sites
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

##### Share on other sites
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

##### Share on other sites
Another difference is with cube-map reflection you can move your camera, but with sphere-map reflection you can''t

##### Share on other sites
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 ?

##### Share on other sites
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

##### Share on other sites
Thank you. I''ll try that.

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632959
• Total Posts
3009465
• ### Who's Online (See full list)

There are no registered users currently online

×