Place transparent texture on material and keep it shaded

Hello everyone,

I’ve got an question:

Im trying to put my transparent texture on my material. I’ve tried different methods etc. but i can’t get it working.
I want to apply my transparent texture to my material but the transparent part of my texture needs to be exactly the same as the material so it also must have the same shaders same color, EVERYTHING.

Currently i’m able to place the non transparent part of the texture on the material without problems.
But the transparent part turns Black and the shaders are lost so the material looks flat :’(.

Anyone know a trick to solve this?

Best Wishes,
Raymond

I’ve the same problem. I want to show my texture.png on material of wathever color i want and i only see black background behind my texture! :frowning:

I solved this by using lighting material instead of unshaded. If you use lighting material the material wont be flat and stays 3d.
if you got any questions feel free to ask

Uh-oh, can you post an example of lighting material usage?

You put it in the Transparent Queuebucket or?

i did this

[java] TextureKey textureKey = new TextureKey(origname,false); <------origname is nameoftexture.png
submesh = (Geometry) rootNode.getChild(“atria”); <------ atria is a mesh

                    submesh.getMaterial().setTexture("DiffuseMap", assetManager.loadTexture(textureKey));
                    submesh.getMaterial().setBoolean("UseMaterialColors", true);
                    submesh.getMaterial().setColor("GlowColor", new ColorRGBA(0.0f, 0.0f, 0.0f, 1.0f));
                    submesh.getMaterial().setColor("Specular", new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
                    submesh.getMaterial().setColor("Diffuse", new ColorRGBA(0.3264f, 0.48720002f, 0.56880003f, 1.0f));
                    submesh.getMaterial().setColor("Ambient", new ColorRGBA(0.408f, 0.609f, 0.711f, 1.0f));

[/java]

1 Like

Ok, thank you very much…the new error at the line below is “NullPointerException”:
[java]
submesh.getMaterial().setTexture(“DiffuseMap”, assetManager.loadTexture(textureKey));
[/java]

This is the code:
[java]
Material mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
mat.setBoolean(“UseMaterialColors”,true); // Set some parameters, e.g. blue.
mat.setTexture(“DiffuseMap”, assetManager.loadTexture(“Models/cellphone/number_1.png”)); // texture with alpha channel
mat.setBoolean(“UseAlpha”,true);
mat.setColor(“Diffuse”, ColorRGBA.Blue);
myGeometry.setMaterial(mat);
[/java]

Here is the result:

no texture with trasparency!

Has anyone a clue?

@raymond7 said: i did this

[java] TextureKey textureKey = new TextureKey(origname,false); <------origname is nameoftexture.png
submesh = (Geometry) rootNode.getChild(“atria”); <------ atria is a mesh

                    submesh.getMaterial().setTexture("DiffuseMap", assetManager.loadTexture(textureKey));
                    submesh.getMaterial().setBoolean("UseMaterialColors", true);
                    submesh.getMaterial().setColor("GlowColor", new ColorRGBA(0.0f, 0.0f, 0.0f, 1.0f));
                    submesh.getMaterial().setColor("Specular", new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
                    submesh.getMaterial().setColor("Diffuse", new ColorRGBA(0.3264f, 0.48720002f, 0.56880003f, 1.0f));
                    submesh.getMaterial().setColor("Ambient", new ColorRGBA(0.408f, 0.609f, 0.711f, 1.0f));

[/java]

Ok, i’ve tested and it’s ok! But i don’t understand why my method won’t function…!

It’s hard to say without pictures. Otherwise “no texture with transparency” right off could mean like two or three different things.

Ok, i made another test with your code but changing diffuse color drammatically change the overall effect changing the texture color too! My texture is contains a yellow number that became black if i set diffuse color to blue…

@pspeed said: It's hard to say without pictures. Otherwise "no texture with transparency" right off could mean like two or three different things.

“><img src=”<img src=“http://i.imgur.com/acJ3QJd.jpg” title=“Hosted by imgur.com” />" alt="" />

The number above is supposed to be yellow…

Yes, well, yellow is red and green… and blue is blue. So when you multiply yellow with blue you get black.

r=1, g=1, b=0
*
r=0, g=0., b=1

r=0, g=0, b=0

But, the yellow number in the texture is supposed to be yellow thanks to the alpha channel with the number 1 zone white (opaque) surrounded by black (transparent). How i can get a yellow number on a surface of another color without color mixing? Could you put an example?

@gnerpo said: But, the yellow number in the texture is supposed to be yellow thanks to the alpha channel with the number 1 zone white (opaque) surrounded by black (transparent). How i can get a yellow number on a surface of another color without color mixing? Could you put an example?

You’d have to write your own shader. JME shaders do not support this sort of decal overlay. The colors are all multiplied together.

I’ve found there is a plugin that is capable to do that, is: ProjectiveTextureMapping.