Search code examples
javafx3dtransparencytransparentjavafx-3d

JavaFX 3D TriangleMesh with transparency


I have a texture I want to use for a TriangleMesh (it's a simple cube). Some parts of the texture are transparent. When I put the texture on the mesh, it's black. Is there a possibility to change that? I would like to make it transparent.

Appreciate your help, thanks


Solution

  • Transparency in JavaFX 3D shapes has been a long time request... until recently: Since JDK8u60 early access release b14, transparency is enabled in 3D shapes.

    You can add color with transparency as diffuse color, like in this answer.

    Also you can add images with some transparency level on every pixel, like this one:

    Cylinder

    where this is the image used with 50% transparency:

    palette

    And you can use full transparency areas too. For instance, in this image, Duke has 50% transparency and the rest is 100% transparent:

    Duke

    Giving this result applying that image as diffuse map over the cylinder:

    Cylinder 2

    Have a look at FXyz project for more details on creating 3D shapes and using textures in many different ways, and the FXyz Sampler.