Skip to main content
gamedev.net
🔒 Locked

Texture-sorting vs. Spatial Sorting

Started by Neophyte Oct 11, 2000 at 2:14 PM 1 replies 300+ views
Original Post
Neophyte
Neophyte
The use of spatial-"sorting" routines, such as BSP-trees and Quad-trees and Oct-trees and what-have-you, seem to be immensely popular these days. Unfortunately, in API''s such as OpenGL state-changes, like changing the current texture, are pretty expensive procedures, and sorting poly-rendering order by location it is not unrealistic to suppose that the current texture is changed as often as once for every 2 or 3 rendered surfaces. So it seems tempting to base the rendering order on textures, and thus render all the polygons textured with a particular texture before moving on to the next texture. The problem is that doing that restricts you to using some sort of depth-buffering technique, and z-buffering isn''t exactly a free operation either. So, my question is this: How high overhead is incurred by changing the current texture umteen times per frame compared to using a z-buffer? Is it, in effect, worth it to render polygons based on which texture they are mapped with (and use a z-buffer for depth), rather than doing e.g. BSP-trees? I realize that BSP-trees have other uses than merely rendering-order (such as simple collision-detection, view-culling, etc.), but I''m not really worried about that here. Any thoughts on this? -Neophyte - Death awaits you all with nasty, big, pointy teeth. -
aanand_420
aanand_420
Well! U r partialy right! But when it comes to transparent/transulecent objects, u need a depth sorting algo. like BSP etc. Z buffer alone won''t do. Sorting polys according to textures is not a good idea when u''ve lots of polys at different Z values using same texture with alpha blending. It''ll be obvious if u try to render polys with alpha blending, but with out depth sorting, u''ll not get the required result.

Hey! Pro''s over there am I wrong?

There is no problem so complicated that it cannot be complicated further.
There is no problem so complicated that it cannot be complicated further.
Ingenu
Ingenu
Okay here''s how you should do:

Outside view volume frsutrum geometry clipping.
Geometry culling (fast using vertices normals)*
Rendering geometry sorted by TEXTURE, MATERIAL, LIGHTING,..
(In priority order)

I also recommend that you read much more Docs on 3D engines cause you would have found this answer easily.
Also you could use you brain :p

Don''t optimize for by Z sorting it''s not worth it.
(Well you could try both and you''ll see what is faster)

Any other question

(No I won''t give you the details of my current 3D engine :p)

-* So many things to do, so little time to spend. *-
-* So many things to do, so little time to spend. *-

Topic Locked

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

Sign in to reply to this topic.