Original Post
Hello! I'm wondering, how do you sort your scene so that alpha blended geometry is drawn last and in order depending on the distance from the camera? It would be easy if I rendered all the geometry in a loop, where one iteration means one object, but that's not the way I do it. I have one big global vertex buffer that contains all the vertices in the scene, and one index buffer per collection of material properties (like texture, alpha blend, color, etc.). All objects that share the same material properties share index buffer. I have a solution: For each index buffer/material, store a list that describes the data in the index buffer and how to render it. Ie, solid objects that don't need sorting is one entry in that list, and objects that do need to be sorted have one entry per object. This is to minimize the number of rendering calls, there will be one call for the solid objects and one per alpha blended object. Another solution: Have two index buffers per material, one for the solid objects and one for objects that need sorting. Then when the camera moves, I just sort the alpha blended objects and write them to the second index buffer. This would also make it easier to implement LOD-surfaces and billboards, they could have their own buffers. What do you think of my ideas? Completely out of whack? Are there better ways?