Jump to content
  • Advertisement
Sign in to follow this  
zacaj

How to determine object depth for sorting

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

For transparency rendering you're supposed to sort your objects by depth, however I'm having trouble finding a good method of choosing each object's depth.  Just using the position doesn't work for objects that aren't centered, getting the center of the bounding box doesn't work much better.  I also tied getting the smallest depth from all six corners of the bounding box, but even that has problems.  Has anyone come up with a good way to do this?

Share this post


Link to post
Share on other sites
Advertisement

You can sort face centers instead. It's slower, but it gives better results. Not necessarily correct results where faces are nearby and with sharp corners, but it's enough most of the time.

Share this post


Link to post
Share on other sites

If your target hardware is powerful enough, you can get all fancy with order-independent transparency.

 

If not, then you are stuck with finding a best estimate. What are you trying to render here? Techniques will vary depending on whether you are drawing camera-aligned particles, cut-away models, or something else...

 

As mrjones says, sorting individual polygons by their centre is a possibility, although likely not feasible due to the sheer number of polygons, and the resulting lack of batching.

Share this post


Link to post
Share on other sites

I'm doing a high end shader based engine and also a software renderer. Just trying to render regular models, no particles or anything fancy, and not worried about transparency within a single object yet.

Share this post


Link to post
Share on other sites

Despite every 3D game having to solve this problem, it's still an unsolved problem unsure.png

 

Using the centre of the object, it's farthest point, or it's closest point are common solutions.

Sometimes you'll use different methods for different objects -- e.g. if the player is inside a 1km glass dome, you want to use it's farthest point (because that's a better representation of where it's surfaces actually are), but maybe for other objects you want to use their nearest point.

Share this post


Link to post
Share on other sites

If its a deferred for transparent objects you can use interlace, deinterlace method (Used for toy story). But it also have some limitation yet no needs for sorting.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!