PDA

View Full Version : Cube Map Texture Selection

zero_t9
04-17-2005, 10:28 PM
Hi,

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

dorbie
04-17-2005, 10:36 PM
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.

zero_t9
04-18-2005, 06:44 AM
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.

knackered
04-18-2005, 07:12 AM
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).