Archived

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

cruZ

Texture Sorting

Recommended Posts

cruZ    133
I have rather huge terrain, and I was wondering how much a texture change (SetTexture in D3D) affects the overall performance. I mean if I have a lot of different visible textures on my terrain, would it be faster to sort the polygones by textures and draw polys with the same texture first? Or is it just a waste of time to sort them?

Share this post


Link to post
Share on other sites
CrazedGenius    156
It''s usually not a waste of time to sort them. Try this - draw all the unsorted polygons setting textures whenever you need to (the mostly worst case). Now try drawing all the polygons, but only set the texture once (the best case). Is there a difference? Is it significant? If so, then you''ll probably want to sort.

Share this post


Link to post
Share on other sites
invective    118
If you use index buffers its not to hard to sort the triangles, even if they are in the same vertex buffer. Just use one index buffer per texture. Note that at least on by Geforce 2, index buffers are limited to words (16 bit) - reference 65,000+ vertices (no dword), so if you have more than that, you need to split up the index buffer.
Alternatively you can just store all the terrain textures one big texture and adjust coordinates accordingly (4 64x64 textures in one 128x128 -- but leave a guard area for mip mapping and filtering or you might get some wierd edge effects).
I don''t know how else you were going to do this. You certainly do not want to render each triangle one at a time and change textures each time -- that will take forever!

Share this post


Link to post
Share on other sites
CrazedGenius    156
Good point - either presort the actual vertex buffer and/or create a sorted index buffer (which is very different from a sordid index buffer). You could do it without an index buffer if you sorted the vertex buffer and then rendered different ranges, but you should be using an index buffer anyway.

In any case, think groups of triangles, not individual triangles...

Share this post


Link to post
Share on other sites