When JavaFX8 code loads the color, bump and spec maps, the color and spec work as expected, but bump map is causing strange effects. All three are Mercator maps of Earth. Generally, there is no 3d effect added by the bump map. Bump map only causes Himalaya and Andes appear on the lit side of the globe as black areas with shiny border and on the shaded side as they appear on the color map. What am I doing wrong?
Image diffMap = null;
Image bumpMap = null;
Image specMap = null;
diffMap = new Image(MoleculeSampleApp.class.getResource("Color Map1.jpg").toExternalForm());
bumpMap = new Image(MoleculeSampleApp.class.getResource("Bump1.jpg").toExternalForm());
specMap = new Image(MoleculeSampleApp.class.getResource("Spec Mask1.png").toExternalForm());
final PhongMaterial earthMaterial = new PhongMaterial(Color.WHITE, diffMap, specMap, bumpMap, null);
earthMaterial.setDiffuseColor(Color.WHITE);
earthMaterial.setSpecularColor(Color.WHITE);
Being new to 3d my first thought is that there should be some kind of scaling pixel color values of the bump map into elevation, which I am missing.
Bump map for JavaFX is a normal map, not a height map, for more info see: normal map and height map info.
Here is a sample you can try.
The images for the maps are pretty large, so it might take a little while to download them before your scene shows.
Source I used for images was => Bored? Then Create a Planet (now a dead link).
The JavaDoc states for the PhongMaterial bumpMapProperty states:
A normal map is used rather than a height map because:
A brief description of both normal mapping and height mapping is provided in the wikipedia bump mapping article.
Sample Images
Update, July 2021
Unfortunately the image source from "Bored? Then Create a Planet" is no longer available, so I updated the answer to link to different images (hopefully those will remain online). Because it is linked to different images, the resultant rendering of earth looks a bit different than the example image above, though it is similar. The code to render is basically no different, though the images changed.
Diffuse map
Normal map
Specular map