Original Post
🔒 Locked
glTexCoord3f??
Advertisement
I would assume it''s for 3D textures.
There''s a glTexCoord4f() as well.
It has to do with texture space, homogeneous coordinates and having to perform perspective correction of texture maps while rasterizing.
Nowadays 3d cards take care of this for you, but in the days of software rasterizers (they are gone right?!? *shiver*) it was up to you. When looking up the texture to determine which color to draw, you had to take into account the deformation of perspective and divide by w (ie 1/z). If you just used linear interpolation across the texture you''d get horrible warping.
The 4 coordinates are usually called u, v, s, t.
When you use the glTexCoord2f version, the s and t values are automatically set to 0.0, and 1.0 for you.
Unless you are doing something very unusual, you''ll never really have to worry about s and t values.
--
Slimy
It has to do with texture space, homogeneous coordinates and having to perform perspective correction of texture maps while rasterizing.
Nowadays 3d cards take care of this for you, but in the days of software rasterizers (they are gone right?!? *shiver*) it was up to you. When looking up the texture to determine which color to draw, you had to take into account the deformation of perspective and divide by w (ie 1/z). If you just used linear interpolation across the texture you''d get horrible warping.
The 4 coordinates are usually called u, v, s, t.
When you use the glTexCoord2f version, the s and t values are automatically set to 0.0, and 1.0 for you.
Unless you are doing something very unusual, you''ll never really have to worry about s and t values.
--
Slimy
3 or 4 texcoords aren''t unusual at all. 3D texturing is just one application for them, but there are many others. BTW, the 4 coordinates are called (s, t, r, q) in OpenGL.
* Projective texturing is very common, and uses minimum 3 coords.
* Cubemaps (reflection maps) also need 3 texcoords.
* Shadowmapping uses the third texture coordinate as a comparison value.
* EMBM (environment bumpmapping) needs 3 coordinates.
* vertex shaders can redefine the 4 coordinates for almost any other use.
/ Yann
* Projective texturing is very common, and uses minimum 3 coords.
* Cubemaps (reflection maps) also need 3 texcoords.
* Shadowmapping uses the third texture coordinate as a comparison value.
* EMBM (environment bumpmapping) needs 3 coordinates.
* vertex shaders can redefine the 4 coordinates for almost any other use.
/ Yann
Little additional info: while 3 coordinates (s,t,r) are encountered pretty often in advanced OpenGL programs, the 4th coordinate (the homogeneous texture coordinate 'q') is rarely used. Setting it to something else than 1.0f is rather unusual, so you are not entirely wrong about that 
An exception are 4D textures. But those are not (yet) available on consumer level hardware. However, lots of high performance engines also specify/transfer the 4th coordinate (setting it to 1), since it it creates a more cache friendly vertex format.
/ Yann
[edited by - Yann L on August 5, 2002 11:07:40 PM]
An exception are 4D textures. But those are not (yet) available on consumer level hardware. However, lots of high performance engines also specify/transfer the 4th coordinate (setting it to 1), since it it creates a more cache friendly vertex format.
/ Yann
[edited by - Yann L on August 5, 2002 11:07:40 PM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement