first off, there is a lot of talk on this topic already but there are no true solutions to this problem.
We got a mesh with a TextureArray and the textures are mostly opaque and some are translucent.
The opaque faces disappear if you look through the translucent textures. It seems that that it is either Alpha-Sorting or Depth-Buffer Sorting problem.
- Draw the opaque part of the world so that the depth buffer already can reject hidden transparent triangles
- Sort transparent triangles, from the furthest to the closest
- Draw the transparent triangles
So far we’ve tried everything we could find in the JME-Forum in every possible combination with no luck.
Is this a general JME-problem or is there no other way of rendering translucent textures in combination with opaque ones on a single mesh?
A solution would be to generate a single mesh for all translucence faces and one for the opaque ones, but due to the sheer size of meshes we would have way too much drawcalls which would affect the FPS and the rendertime for meshes in a very negative way.
This is a general OpenGL Transparency problem. If you draw one pixel at z=100 that is semitransparent then this will block any pixels drawn after at z=100+.
I don’t understand the “way too much draw calls” issue since at best it would double the draw calls. Maybe you are already draw call limited. First it sounded like there was only one object and now you make it sound like there are actually lots of them.
@h1ghst0r3y said:
Is this a general JME-problem or is there no other way of rendering translucent textures in combination with opaque ones on a single mesh?
That's a general issue with transparency, not only a JME issue.
The thing is geometry are sorted as a whole, faces are not sorted with each other in the same mesh. so you may have inconsistency when for example a transparent object is inside another transparent object or that 2 transparent faces are intersecting with each other.
I have one more question. Why can I see the faces behind a face which is transparent (value <= threshold) if I discard pixels in the shader? Is there a way so keep informations from discarded pixels?
@alrik said:
I have one more question. Why can I see the faces behind a face which is transparent (value <= threshold) if I discard pixels in the shader? Is there a way so keep informations from discarded pixels?
Discarded means those pixels aren’t drawn. So nothing goes into the color buffer… but more importantly, nothing goes into the Z-buffer.