Weird transparency behavior

Hello,



I've created a stadium scenegraph and an orbit camera centered to the ball. All works ok, but I have troubles with transparent objects, even if the RenderQueue is set to TRANSPARENT. see the pics:



The ball is hidden by the net





Moving the camera the ball is now behind the net but the back portion of the net is now hidden.




Keep moving the camera: sometimes the net becomes black, no transparent at all. But if you move just a little bit it becomes transparent again..




Move the camera again: now the net is black, transparent against itself..



Any hints ??

Cheers!

Maybe missing a ZBuffer State?


The ZBuffer init code.


ZBufferState buf = display.getRenderer().createZBufferState();
buf.setEnabled(true);
buf.setWritable(true);
buf.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo);
rootNode.setRenderState(buf);
rootNode.updateRenderState();

The black net is caused by it being rendered before the background due to opaque sorting, change its render queue mode to transparent:


net.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);



The back portion being hidden on one angle is a harder problem to fix and has to do with how the triangles are arranged inside the model. Is is impossible to achieve optimal ordering that would lead to correct rendering from all angles  :|

You have some options though:
1. Disable depth write for the net.
This is the best option to use unless you have other transparent objects inside the net.


ZBufferState netZState = ...
...
netZState.setWriteEnabled(false);



2. Use alpha test in your blend state:


BlendState netBlendState = ...
...
netBlendState.setTestEnabled(true);
netBlendState.setReference(0.05f);
netBlendState.setTestFunction(TestFunction.GreaterThan);


This solution will make the net appear a little blocky (you should disable alpha blending as well, as it will look odd with the alpha test on).

The option 2 is working quite well Momoko. It's kind of trick (I didn't know it) but the results are acceptable, so here I am to thank you for the hint!



Now the main question is scenegraph transparency in general.

I'm under the impression that the jme scenegraph does not support "real" transparency in the terms humans are thinking. The results you achieve when rendering a jme scene are different from view angle to view angle and are affected from the order of the spatials in the scenegraph.



Is it a jme issue or maybe this is what I get from any other engine around ?