[SOLVED] How to set an Alpha Color to a Material

Hi,
I want to add a very translucent black to the material of my skid spots.
So I tried:

    if (Spot.material == null) {
            Spot.material = new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
            Spot.material.setTransparent(true);
            ColorRGBA color = new ColorRGBA(0f, 0f, 0f, 0.1f);
            Spot.material.setColor("Color", color);
        }

But no matter if I set the alpha value to 0.1f or to 0.9f the result is always the same.

For transparency you also need to set the BlendMode to alpha in the material’s additionalRenderState, so if you add this it should work:

material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha)

2 Likes

thanks, that does the trick.

1 Like