PDA

View Full Version : wrapping modes for cube-map textures



debonair
04-04-2013, 05:49 AM
I am trying to apply wrapping modes to cube map texture. Here are my tex-coordinates



#define eps1 1.0

GLfloat tex_coords[] = {
/* +X side */
1.0, -eps1, -eps1,
1.0, -eps1, eps1,
1.0, eps1, eps1,
1.0, eps1, -eps1,

/* -X side */
-1.0, eps1, -eps1,
-1.0, eps1, eps1,
-1.0, -eps1, eps1,
-1.0, -eps1, -eps1,

/* +Y side */
-eps1, 1.0, -eps1,
-eps1, 1.0, eps1,
eps1, 1.0, eps1,
eps1, 1.0, -eps1,

/* -Y side */
-eps1, -1.0, -eps1,
-eps1, -1.0, eps1,
eps1, -1.0, eps1,
eps1, -1.0, -eps1,

/* +Z side */
eps1, -eps1, 1.0,
-eps1, -eps1, 1.0,
-eps1, eps1, 1.0,
eps1, eps1, 1.0,

/* -Z side */
eps1, eps1, -1.0,
-eps1, eps1, -1.0,
-eps1, -eps1, -1.0,
eps1, -eps1, -1.0,
};


How to modify my tex-cords so that I can see the repeated or clamped-to-edge texture?

I tried changing eps1 but no use. I have 3*3 texture.

as per specs
"When sampling from cube map textures, a three-dimensional texture coordinate is used to select one of the cube map faces and generate a two dimensional texture coordinate ( s t ), at which a texel is sampled from the determined face of the cube map texture. Each face of the texture is treated as an independent two-dimensional texture, and the generated ( s t ) coordinate is subjected to the same clamping and wrapping rules as for any other two dimensional texture fetch."

Alfonse Reinheart
04-04-2013, 06:48 AM
You apparently missed the part of the spec where the s and t coordinates are based on the two non-major directions, but divided by the absolute value of the major direction. Since the major direction is the direction with the largest absolute value, the result will always be on the range [0, 1]. You can think of it as a built-in normalization of the 3D texture coordinate before doing the look-up.

In short, it is not possible to wrap the faces of a cube map. And really, what would that mean? A cube map is a way of mapping directions to a texture. Directions don't have lengths, and you can't wrap around directions.

What you seem to be looking for is an array texture (http://www.opengl.org/wiki/Array_Texture), not a cube map.

debonair
04-05-2013, 10:49 AM
You apparently missed the part of the spec where the s and t coordinates are based on the two non-major directions, but divided by the absolute value of the major direction. Since the major direction is the direction with the largest absolute value, the result will always be on the range [0, 1]. You can think of it as a built-in normalization of the 3D texture coordinate before doing the look-up.

In short, it is not possible to wrap the faces of a cube map. And really, what would that mean? A cube map is a way of mapping directions to a texture. Directions don't have lengths, and you can't wrap around directions.

Thanks you so much..!!
Just curious to ask, when i change eps1 to 3 i get texture repeated 3 times on each face concentrically and for all the values >3 it repeats 4 times. Could not figure out this behavior, as tex-cords are from the center hence i guess it is concurrently repeated isn't it ? but the count still makes me to think over it.