04-14-2005, 10:55 PM
Suppose I have a 100x100(pixel) picture and I want to map it to a 20 x 20(in object coordinate system) sqaure geometry, then how should I set up the texture coordinates? What factors will decide the number of textures needed in one direction?
1. Determine how big you want a pixel from the texture (i.e. a texel) to be in object coordinates.
2. Divide by the size (in texels) of the texture, multiply by the size (in object coordinates) of the object.
suppose one pixel of your texture is supposed to be 1 unit, and your object size is supposed to be 400.
For simplicity, we'll assume a square object.
With a texture of size 100x100, the texture coordinates would be:
(0,0) for the "bottom left" corner,
(0,4) for the "top left" corner,
(4,4) for the "top right" corner,
(4,0) for the "bottom right" corner.
The 4 comes from having to repeat the 100 texel texture 4 times.
Depending on what you want to achieve, you may actually want to use the glTexGen functions to automatically generate coordinates, or you may want to use an ortho projection (e.g. if you just want to display a pattern instead of 3D geometry).
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.