Z-sorting back to front

I am implementing z-sorting for transparency. Am I correct in thinking that the proper way to do this is one subpass per rendered object? Or will it work correctly if I just make sure those objects are rendered last, in the order I want?

Doing one subpass per object is not what you wanna do. The naive approach would be rendering the transparent objects in the correct order, so that e.g. transparent objects are rendered last, sorted from back-to-front from the camera’s view. If you have multiple transparent objects overlapping then you may need to use something different like order-independent-transparency, which can be simplified in Vulkan using multiple subpasses.

I want to account for multiple layers of transparency, like in the image below which is using three layers of transparency. In OpenGL I would just draw the blended objects after the rest of the scene, in order back to front.

If I add object draw commands into a command buffer sorted back to front, can I assume they will be drawn in the same order? If not, how should I handle this?

Um… why wouldn’t they be? Blending (let alone depth testing and the like) would be a completely non-functional thing if they weren’t.

1 Like

Thank you for the information.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.