I can't figure out, how I to tell libgdx to draw my green spheres behind my transparent decal.
Here is an example picture of my problem:
The decal creation: first two params are width and height, last flag is wether transparent or not.
Decal.newDecal(count * (GUTTER + BUTTONWIDTH) + GUTTER, 2 * GUTTER + BUTTONHEIGHT,
new TextureRegion(new Texture(Gdx.files.internal("icons/uibg.png"))), true);
The sphere creation:
builder.createSphere(
FINGERTIPRADIUS * 2, FINGERTIPRADIUS * 2, FINGERTIPRADIUS * 2,
6, 6,
new Material(ColorAttribute.createDiffuse(Color.GREEN)),
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
And the render method:
this.models = new ModelBatch();
this.decals = new DecalBatch(new CameraGroupStrategy(camera));
...
// adding decals and models to render queue
...
public void update(float deltaTime){
super.update(deltaTime);
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
models.begin(camera);
for (Entity entity : queue) {
ModelInstance model = Mappers.Object.get(entity).instance;
models.render(model, environment);
}
decals.flush();
models.end();
queue.clear();
}
I appreciate every advice.
//EDIT
Added the Blendingattribute to the spheres and a .7 opacitiy. This works. But i guess the problem is somehow between the decal and model rendering, because the grid in the background is a decal and it can be seen through the black transparent decal but the spheres can't.
The new material code:
Material mat = new Material();
mat.set(ColorAttribute.createDiffuse(Color.GREEN));
mat.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.7f));
fingerTip = builder.createSphere(
FINGERTIPRADIUS * 2, FINGERTIPRADIUS * 2, FINGERTIPRADIUS * 2,
6, 6,
mat,
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
Here another picture: the two mid spheres are not rendered behind the transparent decal as they should.