Checked stripes are full alpha, the others are white. The idea is to have the underlying material color show through the transparent stripes. Here’s the code:
@Override
public void simpleInitApp()
{
assetManager.registerLocator("data", FileLocator.class);
flyCam.setEnabled(false);
Material material;
Geometry geometry;
DirectionalLight light;
material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
material.setTexture("DiffuseMap", assetManager.loadTexture("textures/Stripes.png"));
material.setBoolean("UseAlpha", true);
material.setBoolean("UseMaterialColors", true);
material.setColor("Ambient", ColorRGBA.Orange);
material.setColor("Diffuse", ColorRGBA.Orange);
geometry = new Geometry("geometry", new Sphere(64, 64, 1.5f));
geometry.setMaterial(material);
geometry.rotate(FastMath.HALF_PI, .0f, .0f);
light = new DirectionalLight();
light.setDirection(new Vector3f(-.5f, -.5f, -1.0f));
light.setColor(ColorRGBA.White);
rootNode.attachChild(geometry);
rootNode.addLight(light);
}
Where’s the issue?
Also, is material.setColor(“Ambient”, ColorRGBA.Orange); useful in this case? I understand that lights in Phong’s model are made up of three components, but commenting out this line leaves the result unchanged. Why?
Material color will add to the diffuse map (the texture). So the white stripes become orange.
The transparent stripe won’t appear because it doesn’t apply any color to the surface, so the light doesn’t react and it stays black. The orange is surely added to it, but the color still has zero opacity.
Alpha channel on a texture allow you to hide the surface itself (meaning the mesh), not to see throught layers of texture.
If you want to blend many textures on the same material, I think you will need alpha maps, like for the terrain splatting texture
Well, we’d also probably need to know what you expect. @methusalah has done a guess… but really we don’t know what you meant to happen… and what happened is what we’d all expect to have happened.
White stripes become orange because of this line (I guess ^^). Your diffuse map is blended with this color.
And for the a “bleeding” of the ambient color into the transparent areas of the diffuse map, I didn’t know it was possible but yes, I understand the doc like you are. I let someone else give more details about that point.
Sorry about that… the wiki docs are usually the most out of date as it’s based on when someone volunteers to fix them. I think UseAlpha was disabled even before the first 3.0 alpha.
Sometimes the best source for information is the source, unfortunately. Javadoc next, wiki last. Also unfortunately, no generated docs for materials.
Oh I see. Well, no big deal, being forced to delve in the source only brings advantages in the long term. I know nothing on GLSL et similia though, will this be a problem?
You should consider upgrading to 3.1, though… and then you could have just looked at the j3md file to see that the parameter is no longer there. 99.9% sure that the latest j3md finally removed the unused parameters. (We had no way to mark them deprecated so they just stayed unused in 3.0.)
Yep, it’s definitely in my plans after finishing my current project.
Speaking of which, this may be a stupid (and a tad OT) question, but still. I’ve managed to export a .j3o file by means of BinaryExporter (currently I’m not using the SDK), starting from an Ogre XML generated on Blender. Is there a way to the same for j3m’s?
Yeah, open it in the scene explorer… select the geometry, generate materials in the property panel… save it again. Open the .j3m from the assets folder.