I had an absolute nightmare with this!
Hold on…
Found some code that I think did that, but it is really horrible and almost certainly filled with stuff that I put in as an experiment and never got around to taking out. It references CloudBlack.gif, which is an image that literally contains just a white cloud on a black background- the black then get’s alpha’d out, as I recall.
Appearance apster=new Appearance();
Material bob= new Material();
bob.setEmissiveColor(0.9f, 0.9f, 0.9f);
bob.setAmbientColor(0.9f, 0.9f, 0.9f);
apster.setMaterial(bob);
BufferedImage bi = new BufferedImage(128, 128, BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g = bi.createGraphics();
Image inImage = new ImageIcon("C:\\java3dExperiment\\cloudBlack.gif").getImage();
g.drawImage(inImage, null, null);
g.dispose();
ImageComponent2D alpha2D = new ImageComponent2D(ImageComponent2D.FORMAT_CHANNEL8, bi, true, false);
Texture2D texter=new Texture2D(Texture2D.BASE_LEVEL, Texture.ALPHA, 128, 128);
texter.setImage(0, alpha2D);
TextureAttributes texatt=new TextureAttributes();
texatt.setTextureMode(TextureAttributes.COMBINE);
texatt.setCombineRgbMode(TextureAttributes.COMBINE_REPLACE);
texatt.setCombineAlphaMode(TextureAttributes.COMBINE_REPLACE);
texatt.setCombineRgbSource(0, TextureAttributes.COMBINE_OBJECT_COLOR);
texatt.setCombineAlphaSource(0, TextureAttributes.COMBINE_TEXTURE_COLOR);
texatt.setCombineRgbFunction(0, TextureAttributes.COMBINE_SRC_COLOR);
texatt.setCombineAlphaFunction(0, TextureAttributes.COMBINE_SRC_ALPHA);
TransparencyAttributes transp = new TransparencyAttributes();
transp.setTransparencyMode(TransparencyAttributes.BLENDED);
apster.setTexture(texter);
apster.setTextureAttributes(texatt);
apster.setTransparencyAttributes(transp);
This is old code, I don’t recall how well it worked but probably it wasn’t great- I’m mostly posting it in the hope you can get some idea of a way to go…