Alpha masked textures, how ? (newbie)

Hi,

I am just trying to convert the terrin/skybox demo from JCD to allow a semi-transparent ground layer intersecting the terrain at a given height level to indicate water.

Can I load textures (using the standard getTexture func) containing predefined alpha values like in a png image file (e.g. from gimp) ? When I do so I get black opaque pixels for all transparent pixels.

What image formats next to “RGB” can be used ? ARGB, RGBA, BGR, ABGR ?

thanks :slight_smile:

[quote]Can I load textures (using the standard getTexture func) containing predefined alpha values like in a png image file (e.g. from gimp) ?
[/quote]
Yes, it also loads PNGs in RGBA format (that is 24 bpp RGB plus 8 bpp alpha layer in one PNG file).

[quote]When I do so I get black opaque pixels for all transparent pixels.
[/quote]
You need to enable transparency for the Shape3D using the RGBA texture. For example


Appearance ape = <your Shape3D's appearance object>
..
TransparencyAttributes tranat = new TransparencyAttributes();
tranat.setTransparencyMode(TransparencyAttributes.BLENDED);
ape.setTransparencyAttributes(tranat);

[quote]What image formats next to “RGB” can be used ? ARGB, RGBA, BGR, ABGR ?
[/quote]
It happily works with RGB and RGBA. Both directly loaded from a PNG file.
If other formats are possible I don’t know.

wooooorks, thanks a lot :slight_smile: