Cube Map Texture Selection


Upon reading the spec section regarding “Cube Map Texture Selection” below, I am wondering how we should decide the center of the cube? What can I expect if I define six 2D images for a torus? I am a little confused with the results.

3.8.6 Cube Map Texture Selection
When cube map texturing is enabled, the ( s t r ) texture coordinates are treated as a direction vector ( rx ry rz ) emanating from the center of a cube (the q coordinate can be ignored, since it merely scales the vector without affecting the direction.) At texture application time, the interpolated per-fragment direction vector selects one of the cube map face’s two-dimensional images based on the largest magnitude coordinate direction (the major axis direction).

It is an approximation.

The whole assumption of environment mapping is that objects are in an environment that is infinitely distant (or the objects are very small) and they don’t self reflect (generally).

It tends to look very convincing but there are some situations where it breaks down. Especially with large objects near the object that they are reflecting. Other techniques (with their own simplifying approximations) can then be used, like render to texture planar reflections.

Dorbie, HI:

Thanks for your reply. How to calculate the approximation of the center? Is it the geometric center of all primitives being textured when cube map is being enabled and applied?

Originally posted by dorbie:
[QB]It is an approximation.

The centre of the cube is the vertex being considered. The cube map is indexed by a 3D vector (the texture coordinate) from that vertex.
The scheme that you use to generate the 3D vectors (the texture coordinates) is up to you (vertex shader), or up to the automatic texture coordinate generation mode you select (see documentation).