I have been playing around with the Procedural planet generator demo ( http://www.jmonkeyengine.com/forum/index.php?topic=6410.0 )
I have run into a problem which I can't seem to fix though, involving the shader generated cloud effect around the planet.
This code gives the following image:
Planet p1 = new Planet(infos, generator, display.getRenderer());
p1.setLocalTranslation(0, 0, -50);
p1.updateGeometricState(-1, true);
rootNode.attachChild(p1);
Planet p2 = new Planet(infos, generator, display.getRenderer());
p2.setLocalTranslation(50, 0, -50);
p2.updateGeometricState(-1, true);
rootNode.attachChild(p2);
However, here comes the strange part
Planet p1 = new Planet(infos, generator, display.getRenderer());
p1.setLocalTranslation(50, 0, -50); // Swapped
p1.updateGeometricState(-1, true);
rootNode.attachChild(p1);
Planet p2 = new Planet(infos, generator, display.getRenderer());
p2.setLocalTranslation(0, 0, -50); // Swapped
p2.updateGeometricState(-1, true);
rootNode.attachChild(p2);
By swapping the order that I create the 2 planets, the shader created cloud effect becomes opaque. I'm guessing this has something to do with the draw order. If I turn off the cloud shader, then everything works as you would expect. I have tried changing the alpha blending and other options on the shader, but I can't seem to solve the problem. The zbuffer is enabled for the shaders:
zbufferEnabledState = renderer.createZBufferState();
zbufferEnabledState.setFunction(ZBufferState.TestFunction.LessThan);
zbufferEnabledState.setEnabled(true);
...
planetRenderPass.setPassState(zbufferEnabledState);
atmoFrontRenderPass.setPassState(zbufferEnabledState);
atmoBackRenderPass.setPassState(zbufferEnabledState);
Any ideas? :?