JavaFX 3D Tutorial #7 – Reflection with Specular Map

In the 6th chapter, we talked about giving wooden texture to the object. Today, let us see how to give reflection to surfaces in JavaFX 3D. JavaFX provides option to specify specular maps as either image or a color.

Specular Map

Specular maps allows to define a surface’s shininess and highlight colour. The higher the value of a pixel (from black to white), the shinier the surface will appear. Black provides zero reflection and white provides total reflection.

If you want the surface to be having uniform reflection, then use a specular color with Material#setSpecularColor(Color color). Or use Material#setSpecularImage(Image image).

Let’s have a look at the example code.

private Box prepareBox() {
   PhongMaterial material = new PhongMaterial();
   //Set diffuse map
   material.setDiffuseMap(new Image(getClass().getResourceAsStream("/resources/wood.jpg")));
   //Set specular map
   material.setSpecularMap(new Image(getClass().getResourceAsStream("/resources/illuminati.jpg")));

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

and the result will be

JavaFX 3D Box with Reflection

 

Specular Map used

 

 

 

 

Visit JavaFX 3D Course Index Page

Meta titles: JavaFX Reflection, JavaFX 3D Specular Map

Muhammed Afsal Villan

Muhammed Afsal Villan is an experienced full-stack developer, specialized in desktop and mobile application development. He also regularly publishes quality tutorials on his YouTube channel named 'Genuine Coder'. He likes to contribute to open-source projects and is always enthusiastic about new technologies.

More From Author

JavaFX 3D Tutorial #6 – Textures with Diffuse Map

JavaFX 3D Tutorial #8 – Lighting with PointLight and AmbientLight

51 thoughts on “JavaFX 3D Tutorial #7 – Reflection with Specular Map

  1. Pingback: Serviced Apartment
  2. Pingback: Diamond fire
  3. Pingback: ltobet
  4. Pingback: essentials
  5. Pingback: ECs
  6. Pingback: thailand tattoo
  7. Pingback: click to read
  8. Pingback: ricco888
  9. Pingback: Funny videos
  10. Pingback: zbet911
  11. Pingback: เน็ต AIS
  12. Pingback: lost mary
  13. Pingback: live shows
  14. Pingback: นักสืบ
  15. Pingback: Weed
  16. Pingback: Plinko
  17. Pingback: Canadian avodart

Leave a Reply