Maintaining Transparency In Unshaded Materials

Hi there,

Is it possible maintain transparency when using unshaded materials.

I transfer the material to unshaded and it ends up black where the transparency should be.

Would this be a problem in the way the material is created or is this a limitation to unshaded materials?

The unshaded material has no transparency limitation of any sort.
As to what is your issue it’s hard to tell from your question. Some code would have helped.

Asa rule of thumb for transparency, make sure your objects are in the transparent bucket and that the material additionalRenderState is set to Alpha (if you want alpha transparency).

indent preformatted text by 4 spaces    public void makeUnshaded(Node node) {
SceneGraphVisitor sgv = new SceneGraphVisitor() {

public void visit(Spatial spatial) {
  if (spatial instanceof Geometry) {
    Geometry geom = (Geometry) spatial;
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    Material tat = new Material(assetManager, "Common/MatDefs/Terrain/Terrain.j3md");

    if (geom.getName().equals("Invisible")){}  
    else if (geom.getMaterial().getTextureParam("DiffuseMap_1") != null) {
      tat.setTexture("Alpha", geom.getMaterial().getTextureParam("AlphaMap").getTextureValue());
      if (geom.getMaterial().getTextureParam("DiffuseMap") != null) {
      tat.setTexture("Tex1", geom.getMaterial().getTextureParam("DiffuseMap").getTextureValue());
      tat.setFloat("Tex1Scale", Float.valueOf(geom.getMaterial().getParam("DiffuseMap_0_scale").getValueAsString()));
      if (geom.getMaterial().getTextureParam("DiffuseMap_1") != null) {
      tat.setTexture("Tex2", geom.getMaterial().getTextureParam("DiffuseMap_1").getTextureValue());
      tat.setFloat("Tex2Scale", Float.valueOf(geom.getMaterial().getParam("DiffuseMap_1_scale").getValueAsString()));
      if (geom.getMaterial().getTextureParam("DiffuseMap_2") != null) {
      tat.setTexture("Tex3", geom.getMaterial().getTextureParam("DiffuseMap_2").getTextureValue());
      tat.setFloat("Tex3Scale", Float.valueOf(geom.getMaterial().getParam("DiffuseMap_2_scale").getValueAsString()));

    else if (geom.getMaterial().getTextureParam("DiffuseMap") != null) {
      mat.setTexture("ColorMap", geom.getMaterial().getTextureParam("DiffuseMap").getTextureValue());




indent preformatted text by 4 spaces

It’s a method that I use to change an entire scene to unshaded.

It may have to do with the render state you’re talking about.

How would I set “the additionalRenderState to alpha” I can do material.getAdditionalRenderState() but reading through the methods I’m unsure what to do.

Restating your question in a leading way… :smile:
“I want my alpha to blend. Is there a mode for that on the render state?”


:stuck_out_tongue: thanks

No troubleshooting requests in the Development category please (as the label on it says!)

Hi there,

I have a strange issue so I’m brining this back up.

For some reason when I batched the geometries it went back to a black material.

Once again it looks fine in the scene composer and when it switches over it becomes black again.

I have a batched and unbatched version of the model the unbatched works fine, but i need to batch it as it lowers my object count greatly