Sorting transparent objects in Direct3D

Started by
2 comments, last by PhilipLB 15 years, 8 months ago
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?
Advertisement
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.
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.
Quote:I'm pretty sure there is an option or flag in openGL to do that

No, there isn't such a flag.

This topic is closed to new replies.

Advertisement