Archived

This topic is now archived and is closed to further replies.

_vizual_

Question w/ regards to DX Texture Mapping...

Recommended Posts

Hi all, Quite the noob to DX here... Question with regards to texture mapping. I understand that all textures should be stored as images with dimensions to the power of 2 etc.. I've easily been able to take a 512x512 texture and map it to a cube with faces of 512 x 512 each (triangle strips equally a quad that is 512 x 512 ) My question though is, what if I wanted to (hypothetically) draw a rectangle with a flat face and map a *high quality* image of my drivers license to it? the dimensions of the front face of the rectangle will obviously not be proportional to textures saved w/ dimensions to powers of 2.. The front face of the rectangle (3D Drivers License) will have say dimensions 490 x 238. How would I properly map texture of say a high quality pic of my drivers license to such an "quad"? Anyone know what I mean? any help would be greatly appreciated. NOTE: I might be making this sound much more complicated than it really is. I'm just trying to think a bit ahead to some things I might want to do or try. [edited by - _vizual_ on January 6, 2004 1:41:47 AM]

Share this post


Link to post
Share on other sites
There are two ways to solve this. Either scale your texture up to the next power of 2, using a paint package, and then have your quad''s tu and tv values go from 0 to 1. Or, slightly more complicated, just create a texture which is of power 2 dimensions and is large enough to hold your original texture (in this case a 512 x 256), then copy your original texture onto the new texture and work out which texture coordinates map to the corners of the bit you want. E.G.


<---------512------------->
<------490------->
---------------------------
| | |
| Drivers license | |
| texture | |
| | |
|------------------ |
| |
| |
---------------------------


In this case, your texture coordinates would be:
tu from 0 to (490 / 512)
tv from 0 to (238 / 256)

---------------------------------------

Let''s struggle for our dream of Game!

http://andrewporritt.4t.com

Share this post


Link to post
Share on other sites