Jump to content
  • Advertisement
Sign in to follow this  
Spa8nky

[XNA] Animated textures. Which would you consider to be the best approach?

This topic is 3002 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been thinking about animating textures on my models and have come up with the following two ideas:

1) Have multiple textures, each one representing a new keyframe of the animation. Set a new texture each time I want to change to the next keyframe.

2) Create a massive texture and use the texture coordinates to display the area that I want to use for the current keyframe of the animation.

I'm inclined to go with option 1 as it seems easier and I am not limited by texture size.

Which one would you choose or would you go down a different path?

Share this post


Link to post
Share on other sites
Advertisement
I would go with option 2, switching textures is expensive. If you run out of space in your texture you could just add another texture.

Share this post


Link to post
Share on other sites
Quote:

I would go with option 2, switching textures is expensive.


If I am drawing more than one type of model then I will have to switch textures at least once per frame. Unless you know something I don't?

Share this post


Link to post
Share on other sites
I'd go with option 1 for four reasons.

- It's easier to implement.

- It'll perform much better where you don't have enough video memory to hold all the frames at once.

- You won't waste memory if your animations have frame counts that don't fit nicely into a multiple of the texture size.

- It allows you to do things like wrapping the texture coordinates, and scaling the model without weird filtering artefacts.

In cases where all the frames are likely be on screen at the same time and performance is more critical option 2 might be better. Particle systems for example.

Share this post


Link to post
Share on other sites
If there's no wasted space in the large texture, that'd actually take less memory than separate textures, since each texture has an overhead. That said, I agree that option 1 is the way to go. I'm a big fan of choosing the simplest option and only optimising it if there's it turns out to be a bottleneck. Since it doesn't look like the choice here will affect anything else in your program there shouldn't be a problem to change it later.

Share this post


Link to post
Share on other sites
There is sample animated sprite sheet code for XNA on MSDN:

http://msdn.microsoft.com/en-us/library/bb203866.aspx

There is also multiple 3rd party examples available on the web:

http://www.berecursive.com/2008/c/sprite-sheets-in-xna-the-basics

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!