I had some problems with transparency and I made some test. Here is the code:
import com.jme3.app.SimpleApplication;
import com.jme3.font.BitmapText;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue.Bucket;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.shape.Sphere;
public final class MyMaterialTest extends SimpleApplication
{
protected static final Mesh SPHERE_MESH = new Sphere(30, 30, 10);
public static void main(String[] args)
{
MyMaterialTest app = new MyMaterialTest();
app.start();
}
@Override
public void simpleInitApp()
{
Material mat_tl = new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”);
ColorRGBA sphereColor = ColorRGBA.White.clone();
sphereColor.a = 0.25f;
mat_tl.setColor(“m_Color”, sphereColor);
mat_tl.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
Geometry geom = new Geometry(“Sphere”, SPHERE_MESH);
geom.setMaterial(mat_tl);
geom.setQueueBucket(Bucket.Transparent);
geom.setLocalTranslation(Vector3f.ZERO);
rootNode.attachChild(geom);
BitmapText txt = new BitmapText(guiFont, false);
txt.setColor(ColorRGBA.White);
txt.setSize(4f);
txt.setText(“JME”);
txt.setQueueBucket(Bucket.Transparent);
txt.updateLogicalState(0); // TODO remove if fixed in JME3
txt.setLocalTranslation(-txt.getLineWidth() / 2, txt.getLineHeight() / 2, 0);
rootNode.attachChild(txt);
cam.setLocation(new Vector3f(40, 40, 100));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y.clone());
flyCam.setMoveSpeed(40);
}
}
If you move camera around a little (especially to the left) you can see that the text disappears on some camera positions and I don’t have a clue why. Its logical that disappears if you move camera behind it, but not in front.
I suspect this is highly connected with my other problem which I had in JME2:
http://hub.jmonkeyengine.org/groups/general-2/forum/topic/important-rendererqueue_transparent-issue-video/.
I would be really glad if anyone would know something about this strange problem…