PDA

View Full Version : Texture Transform



Roberto
12-10-2014, 01:18 AM
Dear Forum

Im able to apply a Texture to some surface,so basically i know the opengl command
for do this. But I not understand why in the Vertex Processing, we need the Texture Transform
(via Texture Matrix)

Thanks

Roberto

Agent D
12-10-2014, 03:40 AM
You don't _need_ that and nobody forces you to use it, but you _can_ use a 3x3 texture matrix to conviniently rotate, translate & scale the texture coordinates on the surface.

Roberto
12-10-2014, 04:13 AM
You don't _need_ that and nobody forces you to use it, but you _can_ use a 3x3 texture matrix to conviniently rotate, translate & scale the texture coordinates on the surface.

Thanks for reply..but this is not clear again.

Image we assign a square texture to a square geometri; we assign texture coordinate .
Thne vertex pass trough MV matrix and so on......My texture pass trough the same matrix ?
And what is I have the same texture for more geometry??

Opengl is not doing the texture mapping automatically after we assign texture coordinate ?

So, why exist the texture matrix is not clear..

Thanks

Roberto

Alfonse Reinheart
12-10-2014, 05:16 AM
The texture matrix exists because not everyone is assigning "a square texture to a square geometri". The texture matrix can be used to shift texture coordinates, so that the texture appears to slide across a surface. It can be used to rotate a texture independent of the geometry that the texture is attached to, so that the texture will rotate on a surface. And so forth.

The texture matrix exists because it's useful (though not frequently so) to be able to transform texture coordinates before using those coordinates to access the texture.

Roberto
12-10-2014, 09:22 AM
just a pratical precisation:

I apply my texture to the frontal face of my cube..setting texture coordinate.

Than i rotate the cude of 45 degree around y axis...so,now we se my face but not square anymore..
I have to rotate also the texture coordinate ?

Thanks

Alfonse Reinheart
12-10-2014, 09:52 AM
I have to rotate also the texture coordinate ?

No. You're changing the position of the object (which is what the positions control), not the mapping between the object and the texture (which is what the texture coordinates control).

You're thinking about this way too hard.

Yandersen
12-10-2014, 10:04 AM
Roberto, normally the texture matrix is identity matrix, so it's existence has kinda no effect when fixed functionality is used. It is so in case of basic model' skin texturing. But there was a time before shaders, when people were texturing with shadowmaps - the texture matrix was configured in a very special way to do a shadow trick. So basically, you should just leave it aside. In modern OpenGL all those built-in variables and texture matrices are gone anyway, so don't bother. :)

Roberto
12-10-2014, 10:21 AM
Thanks for reply a lot.
Post end.

Roberto

GClements
12-10-2014, 02:07 PM
but you _can_ use a 3x3 texture matrix
The texture matrix is 4x4.

Like vertices, texture coordinates nominally have 4-components; if fewer components are specified, the second and third default to zero while the fourth defaults to one.

The third component is used for 3D (voxel) textures, cube maps, and with the GL_COMPARE_REF_TO_TEXTURE comparison mode (typically used for shadow maps). The fourth component can be used with any texture type if you require a projective mapping.