Jump to content
  • Advertisement
Sign in to follow this  

Depth Sorting With Instancing

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

There's a depth sorting algorithm in my renderer that's straightforward, efficient (at least for a few thousand instances that I tested), and works great. All visible instances are stored in a vector after culling and I sort the vector according to their distance to the camera. Transparent objects show through one another as they should. Now, this is only for multiple instances of one model. But it starts to fall apart when you start adding instances from other models.

They can be distributed in 3D space anywhere no matter which model is rendered first, but I cannot organize the rendering order instances among all models, just on a model to model basis. To show this problem, imagine I have models A and B, and I am bound by the API to render all instances of A before all instances of B, or the other way around.

Given this simple example to demonstrate the problem:

[Camera]----> [A1] [B1] [B2] [A2]

It can't simply go as "render this instance of A first, then these B instances in the middle, and then back to A to render the one farthest from the camera". To do that I need to make a draw call to A twice, and in a situation with hundreds of instances for each, you would need to do that potentially hundreds of times.

Although in practice I won't have as many alpha-blended objects but it would be good to know how this problem is usually handled.

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!