Texture question

Blitz3D Forums/Blitz3D Beginners Area/Texture question

Trek(Posted 2011) [#1]
I’m trying to design textures with efficiency in mind (fps). I know that the smaller the better and the less alpha the better, but what I’m wondering is if how much of the texture file you are not using matters. In other words, if you are designing a home with furniture, each being a unique entity, and they all share the same graphical theme, is it more effective to have one large texture file that encompasses all the needs of the home and furniture and only using certain small portions of that texture file for each entity, or would it be better to have numerous smaller texture files for each entity and therefore using each texture file entirely; Or is this irrelevant because only what’s being mapped on the mesh matters. I hope this makes sense, and if it matters, I use Blender. Thanks


Yasha(Posted 2011) [#2]
There are two main factors that affect performance with "regular" textures:

- the total size of the texture
- whether the texture has alpha on it

How much of the texture is being drawn at a given time, and how many individual texels have alpha, is more or less irrelevant.

As for size, I think the most efficient ballpark is to keep everything between 256x256 and 2048x2048. Smaller than 256 will usually mean wastefulness, and may even be upsized in memory as that's usually the most efficient size for the card to draw. Larger than 2048 may not work correctly on obsolete graphics cards, if you care about that. There should be absolutely no noticeable performance difference though between using multiple small textures and one large texture; the difference is in memory use.

Alpha will usually resolve itself. Performance isn't a problem, but Blitz3D can't draw complex shapes with alpha correctly, so you'll be wanting to split objects with alpha-ed textures into two parts (e.g. for a tree, separate the trunk and the leaves) so that the alpha is only on a simple, convex mesh that can always be correctly Z-sorted. Most of the time this will mean your alpha textures are quite small, as they're limited to details.

Finally, you may get some better results by using the DDS texture format, which is optimized for graphics cards and textures (unlike PNG and so on that are intended for flat viewing). I think this is really just a space improvement though.

Finally, and most importantly, read these:
- http://c2.com/cgi/wiki?ProfileBeforeOptimizing
- http://c2.com/cgi/wiki?OptimizeLater

<CS tangent> Trying to use low-level implementation details like this in advance to create a performant program is almost universally considered a waste of time, and poor design. None of this stuff about textures is going to affect any of the speed bottlenecks in your program. Blitz3D's 3D engine is fast - just let it do its job, 99% of which is done in hardware and thus not really affected by your design choices anyway (and variable from machine to machine). Write sensible code and you'll get good results from it. You're working in a slow language anyway... </CS tangent>


Trek(Posted 2011) [#3]
Extremely helpful answer, thank you Yasha


John Blackledge(Posted 2011) [#4]
I found DDS surprisingly fast for loading, despite the large filesize.
Also, I'm sure I gained quite a few fps by the freeing up of normal memory.


John Blackledge(Posted 2011) [#5]
Whoops. Now see this post:
http://www.blitzbasic.co.nz/Community/posts.php?topic=95636