Controlling draw sequence within an object

Hi all,



I have a 3d model being generated automatically (custom mesh, vertices, etc).



This model is both transparent and intersects itself - which is causing me some headaches. I need depth write on - but with it on then items drawn in the wrong order are not drawn in behind the thing they are behind (so appear to end abruptly when they reach the intersection point).



I have a few potential ideas but thought I’d throw the topic out for discussion to see if anyone had some suggestions.



Possibilities:


  1. Split the object into two (or more) geometries and make sure they are rendered in the correct order (custom sorting on transparent bucket?)
  2. Redesign the object to remove the intersections (or at least move them to non-visible locations)
  3. Control the rendering order of the parts within the geometry. Is this even possible? How would I do it?



    At the moment I’m thinking I’ll probably go with (2) but if anyone has any good suggestions for (3) or any bright ideas for (4), (5), etc then I’d like to hear it :slight_smile:

A mesh is a mesh. You can’t control what order it is rendered in, really. So options (1) and (2) are the only ways. You might also be able to roll your own screen door transparency.



Can you describe more about the shape?

I was hoping that maybe I could use the order of vertices and/or triangles in the mesh to influence the draw order but that doesn’t seem to be the case.



You can think of it as like a localised force shield and then energy penetrating the shield. I would post a screenshot but I did a bit of experimenting with (2) and I’ve managed to get rid of most of the intersections so it doesn’t really show any more. I’m still interested in this subject for future reference though (and in case I find I do need those intersections).

@zarch said:
I was hoping that maybe I could use the order of vertices and/or triangles in the mesh to influence the draw order but that doesn't seem to be the case.

You can think of it as like a localised force shield and then energy penetrating the shield. I would post a screenshot but I did a bit of experimenting with (2) and I've managed to get rid of most of the intersections so it doesn't really show any more. I'm still interested in this subject for future reference though (and in case I find I do need those intersections).


I'd still be interested in a picture so I can understand what you are describing. If you have time and motivation.

Glad you got it sort of working, though. Transparency can be a pain.

This is the modified version: I’ve shortened the point at the front of the yellow and reduced the hight of the “wall” so the intersections are much reduced.



The problem before was that sometimes it was drawing in the red the other side of the yellow, and sometimes not - which when they could potentially penetrate quite a long way was very visible.



Now the overlaps are small enough (particularly since you never see it this close without using the debug camera) that it doesn’t cause issues.



http://www.zero-separation.com/temp/hdxTransparency.jpg