Mesh with transparent textures and rendering order


    Feb 25 2020 | 2:11 pm
    Hi, I know similar problems have been raised in the past but I'm still struggling to find a workaround. Here is the setup : I have two mesh with their own texture, both including transparency. When mesh B is in front of mesh A, I can see mesh A through the transparent areas of mesh B, as expected. But when doing the opposite (mesh A in front of mesh B), transparent areas of mesh A are only filled with the world's erase_color, hiding mesh B behind. This is what I would like to fix. From my understanding this is the expected behavior of openGL, as for each frame mesh A is rendered first, before that mesh B even exists in the 3D environment. I tried to dynamically change layer numbers depending on mesh position relatively to each other (give the higher layer number to the mesh with the smallest z position in order to make it being rendered first) but this solution can only work properly when working with flat parallel planes.
    Is there any other workaround I should be aware of ? I bet something can be done by doubling each mesh and layering each of them in a way there will always be an iteration of mesh A being rendered both before and after mesh B, or maybe using face culling, but all my attempts where wrong.
    Just to let you know : the final patch I'm working on uses quite complex mesh with varying geometry , and I'm still on Max 7. Here is an example patch showing the behavior I'm talking about :
    EDIT: after keep searching, I found Rob saying this (back in 2013): "if you want to overlay transparent shapes, you must do three things. disable @depth_enable enable @blend_enable control drawing order explicitly with @layer attribute, back to front. so @layer 1 objects will be behind @layer 2 objects.
    if you don't specify layer attribute, the order the objects are drawn is unknown, and will possibly change as you add objects to your scene."
    It seems to confirm my thoughts, even though I need do to keep depth_enable enabled on my mesh otherwise I get some ugly glitches. So can someone confirm I have no other way than layers to get proper transparency between two mesh (which still results to ugly things when the mesh are overlaping each other) ? Maybe is there any better solution with Max 8 and GL3 ? Could lead to a huge motivation to update :D