The previous material was opaque, but materials can also be semitransparent. Applying a semitransparent material makes the geometry partially see-through and blends the geometry's color with what is visible behind it. For this, you need an image file with an alpha channel that has grayscale in it.
Let's try to create a fancy window:
Copy the
assets/Textures/mucha-window.png
image to your project'sassets/Textures/
directory.Back in
TexturesOpaqueTransparent.java
, add the following code in thesimpleInitApp()
method:Box windowMesh = new Box(new Vector3f(0f, 0f, 0f), 1f, 1.4f, 0.01f); Geometry windowGeo = new Geometry("stained glass window", windowMesh); Material windowMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); windowMat.setTexture("DiffuseMap", assetManager.loadTexture("Textures/mucha-window.png")); windowMat.getAdditionalRenderState(). setBlendMode(BlendMode.Alpha); windowGeo.setMaterial(windowMat); windowGeo.setQueueBucket...