Hi,
I’ve been running into an issue with transparent objects having their transparent zones not taking the color of the object behind them, but rather the viewport’s background color.
Here is a test case.
[java]package temp;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.renderer.queue.RenderQueue.Bucket;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad;
public class TestTemp extends SimpleApplication
{
public static void main(final String[] args)
{
new TestTemp().start();
}
@Override
public void simpleInitApp()
{
flyCam.setMoveSpeed(10);
viewPort.setBackgroundColor(ColorRGBA.Blue);
final Material mat1 = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat1.setColor(“Color”, ColorRGBA.Red);
final Geometry obj1 = new Geometry(“Background”, new Quad(2, 2));
obj1.setLocalTranslation(-1, -1, 0f);
obj1.setMaterial(mat1);
obj1.setQueueBucket(Bucket.Transparent);
rootNode.attachChild(obj1);
final Material mat2 = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat2.setTransparent(true);
mat2.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
mat2.setColor(“Color”, new ColorRGBA(0, 1, 0, 0.5f));
final Geometry obj2 = new Geometry(“Foreground”, new Quad(1, 1));
obj2.setLocalTranslation(-0.5f, -0.5f, 0.1f);
obj2.setMaterial(mat2);
obj2.setQueueBucket(Bucket.Transparent);
rootNode.attachChild(obj2);
}
}[/java]
As you can see, this simply creates one big red quad, and one smaller half-transparent green quad in front of it.
If you run it, you’ll see what should be expected: the half-transparent green quad merges color with the red quad behind it, giving it a brown tint:
But if you press the W key (or any key to move the camera really), you get this:
The half-transparent green quad is now merging with the blue background color!
It seems to happen whenever the camera is not directly looking at the green quad. Either looking at the green quad directly or moving close to it fixes the problem. But is it possible to make it do the right thing no matter the camera angle?
Thanks.