Daily 09/22/03 Supplement
This weekend, just days before the demo, we came across a major
Texture thrashing was our single largest contributor to a recent framerate
drop. We added 50% more textures on Friday and this pushed our 64 meg video
cards over the edge. Instead of the clean 60+ frames, my laptop went down to 1~2
After much discovery I found out that our textures are just way to big. They
were cool to play with. Unfortunately, as the number rose our framerate dropped.
Our biggest offender was the colony ship texture coming in at a whopping
2048x2048. In reality, our colony ship in full screen didn't take up more than
500 pixels on the screen. A gross waste.
What we want to strive for to get clean artwork is a 1:1 pixel to texel
mapping. What does this mean? It means that if your texels are less than one
pixel in size, you're not getting full texture fidelity. Not a big deal, but it
can look as bad as some bad texture stretching. Especially if your texture has a
lot of detail like ours. So you want to scale your texture so that it roughly
matches at full zoom. Also, if we can get away with a lot less detail in the
texture, we can shrink it again.
Looking at games like Homeworld2, you can tell that they do a lot of custom
texture management. It's really evident if you set it up so that you get a
really low framerate. If you zoom in on a ship real fast, you'll see the texture
mip levels recalculate on the fly. It's pretty cool.
Here's some texture math for our artists so that they have an idea of what
Disclaimer: This is a pseudo artist's rendering of the problem. It's meant
for artist eyes. If you're a programmer, you know that it's different then this
Here's an example of bad texture usage. This is where thrashing happens.
Notice that not all the textures don't fit into memory at one time. The time to
swap out a texture becomes significant. Also notice that the textures aren't
scaled to the size or importance of an object. For instance, the phasor blast
isn't more than 20 or 30 pixels on the screen. There's no reason it should be
close to the size of a star texture that can take up the entire screen.
Here's an example of good texture usage. Notice that all the
textures are fit into memory and their sizes are roughly equivalent to their
importance and size on the screen.
This image gives you perspective on texture sizes. In on
2048x2048 texture, you can fit:
4 - 1024x1024 textures
16 - 512x512 textures
64 - 256x256 textures
256 - 128x128 textures
1024 - 64x64 textures
So, the bottom line. Watch your textures closely. Don't make
them larger than they have to be. They'll eat your framerate alive!!!