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 :’(.
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
[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));
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]
[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…!
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…
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.