Sign in to follow this  
unexist

Sorting transparent objects in Direct3D

Recommended Posts

Is there a function call or render state of some sort to automatically render objects back to front sorted by the z component after being transformed into viewspace or do I have to set this up myself?

Share this post


Link to post
Share on other sites
Sorry dude, there is no function nor render state that does that. you will have to write your own. Just sort your objects by cameraposition dot each object position and store that into an stl map that holds the index and a vector of objects for each index. Then iterate through the map and draw everything. One of the cool things is that you do not need to sort it every frame. You only need to sort only when the camera moves or when objects moves.

Share this post


Link to post
Share on other sites
Thanks. That's good to know. I'm pretty sure there is an option or flag in openGL to do that, but I guess not in directX. I can't use the method using the STL map you mentioned. I'm trying to blend particles made up of quads from several particle systems that all move each frame. The camera will likely move each frame as well so I may as well sort per frame. This is going to be painful to recode since I now realized I'm going to have to sort every single particle that is being rendered from every single emitter I have. I'm going to be refilling the data structure per frame so I'm probably going to write some sort of smart insert data structure.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this