Jump to content
  • Advertisement
Sign in to follow this  
Kitasia

OpenGL Methods against Z-Sorting and question

This topic is 3930 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

Hello everyone. I was just wondering if someone could help poke holes in a theory and answer a quick question! I'm not a big fan of Z-sorting and I'm working on a 3D game using many 2D images. Each image has special properties and what not, so drawing 1 2D character with 140 triangles can be as demanding as drawing a 3D character with 1000 triangles. This is just a brief background. On to Z idea! Well I was tired of using a point sprite drawing method so I tried using a linear drawing style. As you many of you know, this is where Z sorting becomes a pain. I thought I'd be fine with this but then I thought of floating on water. If the water is transparent, and the spite is alpha blended I'd run into an drawing issue. Depending on the order, I'll have an ugly cut out outline of the characters transparent pixels, or quite simply, the part of the character in the water just isn't drawn. To beat this I just drew the water once before the character and disabled depth buffer writing, and drew it again normally after drawing the character. I was just wondering is this a practical idea? Also I was wondering if there was a way to speed up my character count. I've asked this a million times : D but I dunno maybe there's a new technique or something seeing how fast technology moves. Currently I've taken some advice and move all my textures to one file and drawn the polygons as a triangle list. The list, however, breaks whenever I need to draw an image with stencilling effects. I would've hoped things move much faster than they do though. (Can only draw about 5 characters (150 triangles) at 60fps on a intel integrated card). Feels like I had a better handle on this using OpenGL, although I like the overall presentation using XNA. Give and take I suppose. It would probably help alot if I could somehow stencil inside a texture list then draw all my characters on a single triangle list.

Share this post


Link to post
Share on other sites
Advertisement
If you are sprite based then z sorting isn't actually that bad. Using a fast radix sort you might be able sort just about any size list for perhaps 40-50 clock cycles per item. So 65K items at 30fps is maybe about 10% of your 1GHz CPU load.

Of course you might be able to speed this up even more if the objects stay mostly in z order between frames, switching to another sort and distributing the sorting across multiple frames, having near correct z ordering...

Also could try grouping and sorting the groups to avoid large sorts...





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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!