I’m not sure if i understood the transparency of materials right. What I want to do is have multiple objects which all look the same but some ore more transparent than others. With transparent I mean the texture does not have local transparency, but the complete object can be seen through. So Basically I want to have a global transparency for objects. What is the best way to achieve this? Is it even possible to share one material among the objects and still have different transparency values?
I don’t think you could do this, you want to use the same instance of something, but have this same instance be different, in different instances… what you want to do doesn’t make sense. If you want different instances of a material, you need to use different instances of that material.
If you are using simple RBGA color for your material, i would use constant RBG values and the have a loop which creates of an array of material with the varying alpha value that you desire.
Actually the behavior changed a bit with the latest stable update. Materials should always be single instances so you can modify their parameters on each geometry separately. This however has introduced some other issues. If you want multiple geometry to have the same material now you have to set it on a super node. Else, as said, with the latest stable updates all geometries materials are separately editable.
I stand corrected… wouldn’t be the first time
Actually I don’t use a plain color, I use the Material “Common/MatDefs/Light/Lighting.j3md” with a png picture as diffuse map. How would I set transparency in this situation? I want to avoid manipulating the texture as I use it on all of the different instances of my object.
Set the diffuse color of the material to something with an alpha value and UseMaterialColors to true.
In case I get the parameter names wrong a little:
I actually allready did this, but doing so makes my texture disapear. I seam to do something wrong there as setColor(“Diffuse”, new ColorRGBA(1.0f, 1.0f, 1.0f, 0.9f)) makes my objects transparent but black where they should be white (or textured). Do my objects for some reason ignore the lights I set? If I don’t do setBoolean(“UseMaterialColors”, true) the objects get lighted as expected, but of course the color has no transparent effect.
Maybe set ambient color.
Ok, this works as I wanted it:
[java]Material mat = new Material(SharedData.assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setColor("Diffuse", new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f));
mat.setColor("Ambient", new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
mat.setBoolean("UseMaterialColors", true) ;
Thanks for the help.