JavaFX 3D Tutorial #10 – Self Illumination

0
175
JavaFX Self Illumination Example

In JavaFX 3D, you can make use of self illumination maps to provide glowing effects for objects. Self illumination allows to add extra details for the objects.

Self Illumination Map

Self illumination map allows to add an additional glow to the image. You can see the effect in the following image.

JavaFX Self Illumination Example

JavaFX PhongMaterial provides an option to set illumination map using the method

public final void setSelfIlluminationMap(Image value)

It takes an image as parameter. The glow color will be the color used in image. A dark pixel doesn’t contribute to the glow. For example, in the above earth illumination case, I have used following illumination map.

Earth’s illumination map

 

PhongMaterial material = new PhongMaterial();
material.setDiffuseMap(new Image(getClass().getResourceAsStream("wood.jpg")));

//Set self illumination map
material.setSelfIlluminationMap(new Image(getClass().getResourceAsStream("illuminationMap.jpg")));

Box box = new Box(100, 20, 50);
box.setMaterial(material);
return box;

 

Visit JavaFX 3D Course Index Page