In the last chapter, we saw how to create glowing objects with self illumination. In this chapter, we will see about bump mapping in JavaFX.
According to Wikipedia, Bump mapping is a computer graphics technique for simulating bumps and wrinkles on the surface of an object. Surfaces are not always super smooth. They mostly have some form of deformations. Bump mapping allows to add this extra detail to the surface.
JavaFX PhongMaterial provides option to set bump maps using the method.
public final void setBumpMap(Image value)
Let’s have a look at example code snippet.
PhongMaterial material = new PhongMaterial(); material.setDiffuseMap(new Image(getClass().getResourceAsStream("wood.jpg"))); //Set bump map material.setBumpMap(new Image(getClass().getResourceAsStream("bumpMap.jpg"))); Box box = new Box(100, 20, 50); box.setMaterial(material); return box;