Transparency Problems

I’m trying to create a semi-transparent box. However, there is no transparency whatsoever.



[java]

Material mat2 = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

mat2.setColor(“Diffuse”, ColorRGBA.Green);

mat2.setTexture(“AlphaMap”, w);

mat2.setTexture(“DiffuseMap”, x);

mat2.setBoolean(“UseMaterialColors”,true);

mat2.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

geom2.setMaterial(mat2);

geom2.setQueueBucket(Bucket.Transparent);

rootNode.attachChild(geom2);

[/java]



Image being used for transparency:



http://i.imgur.com/rdbVO.png



Any help on what’s wrong? I suspect it’s the texture itself, but I don’t know just what is wrong.

try adding an alphaThreshold or something

What’s an alphaThreshold? Is it the brush’s opacity? I have it, and tested with a 0% background, and with a 50% and 100% stripe.

Actually if you use an alphaMap the alpha value is multiplied with the alpha of your DiffuseMap

Make sure you have a 1.0 alpha channel in your diffuse map (white)

No luck. Even using an empty texture (went to Photoshop, new layer, CTRL-A and deleted everything), the geometry was not transparent.

@memonick said:
No luck. Even using an empty texture (went to Photoshop, new layer, CTRL-A and deleted everything), the geometry was not transparent.


What does it look like?

The texture looks like a chequers board in Photoshop and the in-game cube looks as solid as anything. No hint of transparency. It shows its Diffuse Map Texture.

What happens if you leave out the UseMaterialColors and the setting of the Diffuse color?

If this is what you meant;



[java]Material mat2 = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

mat2.setTexture(“AlphaMap”, w);

mat2.setTexture(“DiffuseMap”, x);

mat2.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

geom2.setMaterial(mat2);

geom2.setQueueBucket(Bucket.Transparent);

rootNode.attachChild(geom2);[/java]



Then same thing happens. The cube renders. However, where there is white in the Diffuse Texture, it’s displayed as white. No transparency.

Any help? I even created a material with a 0.1 Diffuse Alpha, but it didn’t work.



[java]geom2.setMaterial(assetManager.loadMaterial(“Materials/newMaterial.j3m”));

geom2.getMaterial().getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

geom2.setQueueBucket(Bucket.Transparent);

rootNode.attachChild(geom2);[/java]



PS I’m using a Lighting Material - could that be the problem?

What happens if you use w as your DiffuseMap?



The alpha map uses the color of the pixels and not the alpha. One guess is that your alpha map is all white but with transparent parts.

1 Like

It worked. I removed the alpha map and made ‘w’ the Diffuse Map and it worked well. Thanks.

So your alpha map is all white with some different alpha. That’s not what an alpha map is.

White is solid, black is transparent… anything in between is in between.

I had done that, but this is the result when I make a white strip from corner to the opposite corner:



http://i.imgur.com/CkSdl.png

@memonick said:
I had done that, but this is the result when I make a white strip from corner to the opposite corner:

http://i.imgur.com/CkSdl.png


Show me the map used in that picture.

Alpha Map:



http://i.imgur.com/gHkA3.png



Diffuse Map:



http://i.imgur.com/HCDZR.jpg

Try a plain white diffuse map.



It looks like the white diffuse map = colour…but you have a stripe of black diffuse down the middle of your white alpha…



(put it on a coloured background and you will see something you don’t expect I think).

1 Like

My bad - there was transparency with the above picture. The green border were just some different coloured pixels. Thanks anyway zarch.