three-d icon indicating copy to clipboard operation
three-d copied to clipboard

Sort triangles inside a transparent mesh based on distance to camera

Open asny opened this issue 4 years ago • 3 comments

If a mesh is transparent and the blend mode is not ADD, the triangles has to be rendered back to front which requires sorting them cpu-side. In principle it should be done every time the camera changes, but can probably be done less often.

See also discussion in #141 .

asny avatar Nov 01 '21 07:11 asny

As this issue is still open, I assume this is not yet implemented? I was looking into the issues surrounded by this topic a little and found that there is a function that is not yet used properly. Is this where the problem is left at?

Nevsden avatar Feb 06 '24 13:02 Nevsden

This is not yet implemented no. The issue here is about sorting the triangles inside a mesh which is not easy to do fast. The function you refer to sorts the mesh instances which is implemented and working.

asny avatar Feb 23 '24 15:02 asny

Maybe that was obvious 👆 But we can't just use that same approach because sorting all triangles that way every frame is super expensive. If we do that, I will get a lot of issues about the application being slow 😆 We could sort the triangles CPU-side at some frames instead of all frames, but that's also not very easy to implement so it generally works and doesn't affect performance too much. There's another approach called order independent transparency but that is not super easy to implement in a generic way, I haven't had time to think if it's doable, that's why this issue haven't had any progress.

asny avatar Feb 23 '24 15:02 asny