Skip to main content
gamedev.net
🔒 Locked

Texture Mapping Question

Started by jrmiller84 Sep 16, 2005 at 8:56 AM 5 replies 500+ views
Original Post
jrmiller84
jrmiller84
Hey everyone. I just began working on my first side scroller in dx and I've run into a problem which I can think of ways to solve, but I want to make sure I'm doing it the most efficient way. I decided that since I'm a horrible artist (hence why I'm a programmer) I'd recreate one of my favorite SNES games using the sprites from that game. Well upon organizing the sprites in a logical way I ran across a problem. I understand all textures are to be mapped using a 0 to 1 floating point number system, where 0,0 is the top left corner and 1,1 is the bottom right corner. Now for some reason I can't seem to use smaller than 1 point of precision on my textures which limits me to what amounts to a 10 by 10 grid of sprites (100 total sprites). Is there any way to increase the precision? I have a total of 173 sprites I believe. Now I suppose the work around would be to use two different textures and switch them but it seems like it would be a resource hog to load another texture in the middle of an animation. Any insight would be awesome. Thanks everyone!
I will forever be a student.
WhatEver
WhatEver
I'm going to assume for now that your sprites are frames of animations. If this is the case, then it would be ineficient to change textures durring an animation. If I am wrong and they are just single animation sprites (173 individual images without any kind of animation), then you might want to group the sprites together based on the progress of your game. i.e. if the level your playing doesn't contain any carrots, or viles, or whatever your game sprites are, then don't include them into the texture for that level.
WhatEver
WhatEver
You lost me at the point precision however. If you have 10x10 sprites, then that means your texture coordinate offsets would be the result of 1.0f/10.0f. But if you want 20x20 sprites, then the texture coordinate offsets would be 1.0f/20.05. Of course at 20x20 your sprites would be half the size of the ones on a 10x10 scheme.
jrmiller84
jrmiller84
Ok, you seem to have lost me as well. Ok, Im talking about the sprites for just one of the characters so it won't contain any other sprites that are not specific to that character. My understanding of texture mapping is that all textures are mapped based on a 0.0f to 1.0f coordinate system. This means that 0.0f, 0.0f is the top left hand corner of the texture and 1.0f, 1.0f is the bottom right hand corner. Now with that in mind, the texture cordinates can never exceed 1.0f so they have to be split into fractions of that 1.0f ceiling. So then you are limited to 0.0f, 0.1f, 0.2f, 0.3f etc until you hit 1.0f. This means you can only map 100 sprites since your rows and collums of sprites can never exceed 10 (essentially a 10x10 grid of sprites). Now what I am asking is if there is any way to increase the precision of the texture coordinates to possibly make it accept 2 digits of precision so you could effectively have a 100x100 grid of sprites. Then the coordinates would be 0.00f, 0.01f, 0.02f, etc until you hit 1.00f. Does this make more sense? Let me know if I'm going about mapping my sprites/textures the hard way.
I will forever be a student.
technic
technic
Why don't you use 0.05, 0.10, 0.15, 0.2... etc. to pull sprites out of your texture map? You can definitely index UV sampling coordinates with values that aren't always 0.1, 0.2, 0.3, etc.
jrmiller84
jrmiller84
Hmm, maybe I did something wrong but when I tried using 2 point of precision I got a white box instead of a textured box. I'll attempt it again and see what happens. I might have received some misinformation as to the bounds of texture mapping somewhere.
I will forever be a student.
WhatEver
WhatEver
"Now what I am asking is if there is any way to increase the precision of the texture coordinates to possibly make it accept 2 digits of precision so you could effectively have a 100x100 grid of sprites."

It should be inherent. What function call are you using? Maybe show us a code snippet?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.