Heightmap problems

I have problem with heightmaps.

Example heightmaps that comes with sdk, works fine (mountains*.png, etc), but if I create my own, it is just a plane.

And if I open ie mountains512.png, save it and try to use that heightmap, it is just a plane (no errors on log).

I tested ms paint, paint.net, and Artweaver Free 3.0, and didnt got heightmaps to work.

And if I save heightmap.jpg , I got

java.lang.UnsupportedOperationException: Image format: BGR8

What program I should use to create heightmap image?

And when tried using terrain-demo in my Android phone, I got exceptions

when using sdk heightmaps (ie Textures/Terrain/splat/fortress512.png ) :

I/MaterialDef( 3316): INFO MaterialDef 18.03.39 Loaded material definition: Terrain

W/System.err( 3316): java.lang.UnsupportedOperationException: Image format: RGB565

W/System.err( 3316): at com.jme3.terrain.heightmap.ImageBasedHeightMap.getHeightAtPostion(ImageBasedHeightMap.java:170)

W/System.err( 3316): at com.jme3.terrain.heightmap.ImageBasedHeightMap.load(ImageBasedHeightMap.java:135)

W/System.err( 3316): at com.jme3.terrain.heightmap.ImageBasedHeightMap.load(ImageBasedHeightMap.java:83)

W/System.err( 3316): at mygame.Main.simpleInitApp(Main.java:112)

W/System.err( 3316): at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:228)

W/System.err( 3316): at mygame.Main.initialize(Main.java:62)

So on android, I couldnt get terrain work at all.

Is your heightmap greyscale? I don’t know any of these programs but on gimp & photoshop its image - mode - greyscale. should be similar in any of these other programs.

1 Like

Installed GIMP and noticed that my heightmap was ‘indexed’, not grayscaled. Changed it and now .png and .jpg files works (on desktop), thanks.

I still have problems with android, that same Exception as above (RGB565 format) comes with my new heightmaps.

I’m sorry, I’ve never tried development for android, you would have to ask someone more experienced about that

Why don’t you upload your height & splat maps, and also your code. Maybe I or someone else could have a look.

Well, code was just the same terrain tutorial code, and I used images from sdk as well.

I think android converts images to RGB565 format when loading them, so I added




after heightmap is loaded, to avoid exception.

But in ImageBasedHeightMap.java, line 108


ByteBuffer buf = colorImage.getData(0);


on android, buf==null.

Some more testing, and added


// HEIGHTMAP image (for the terrain heightmap)

//Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/1.png");

Texture heightMapImage =new Texture2D(64,64, Format.Luminance8);

// create random terrain

ByteBuffer b = ByteBuffer.allocate(64 * 64);

for (int q = 0; q < 64 * 64; q++)


b.put((byte) ((q % 4) * ((q + 1) % 3)));




so instead of I load an image, I create 64x64 bitmap and fill it with some random values.

It works on android too,

So Texture.getImage().getData(0); does not work on android.