[SOLVED] Heatmap vertex color problem

You said that i could still do it with custom meshes. Do you know how i could do a mesh which consits of 4 patches. Or what do i have to do for the mesh to go over the whole terrain.

consits of 4 patches

well not sure what you mean.

Anyway i just made a simple shader:

is this video what you want?

in vertex shader:

varying float height;


vec4 modelSpacePos = vec4(inPosition, 1.0);
gl_Position = TransformWorldViewProjection(modelSpacePos);
texCoord = inTexCoord;
wPosition = TransformWorld(modelSpacePos).xyz;


height = wPosition.y;

in fragment shader:

varying float height;


gl_FragColor.rgb = vec3(height/50,0,0);

(50 value depends)

Yes that’s what i want. :+1:
Only that the coords of the “Mountains” is being applied from the database and not by mouseclick.

And with shaders would there be a possibility to make it fade from green to red?

Where should i implement the code you wrote?

you can look at JME tutorials about JME Terrain, (in forum on left up is Wiki, search there)

so instead of loading heightmap from image/file you do it like:

AbstractHeightMap heightmap = new AbstractHeightMap() {
    public boolean load() {
        size = terrainSize;
        // clean up data if needed.
        if (null != heightData) {
            heightData = new float[size * size];
            // transfer temporary buffer to final heightmap
            for (int i = 0; i < size; i++) {
                for (int j = 0; j < size; j++) {
                    setHeightAtPoint(GETYOURHEIGHT(j,i), j, i);
        return true;


setHeightAtPoint(GETYOURHEIGHT(j,i), j, i);

GETYOURHEIGHT will be some of your method that get height for j,i coords

So should i put the AbstractHeightMap into the constructor?

What am i supposed to do with the vertex and fragment shaders, or where should i put the things that you wrote there

I’m a bit confused right now :smiley:

Where should i implement the code you wrote?

well i cant do all school project for you, because it would be not fair :slight_smile:

  • everything you have in wiki or in forum posts. like i said when you will look at JME Terrain Wiki -you will know where you need put this code.
  • Also when you will look at simple shaders, you will know where put this lines too.

And with shaders would there be a possibility to make it fade from green to red?

just change line about color to:

gl_FragColor.rgb = vec3(height/20,1 - height/20,0);


1 Like

Thank you :slight_smile:

Is there any difference when doing it with the mouse or just putting in coordinates in the heightmap?

Ill try to find out where I have to put the lines in, wish me luck :smiley:

no there is no difference.

the only difference as you see i got there “Grid” and i got bloom filter that make tip of mountain yellow color arround. you dont need it and you will not have it so dont worry.

How do i get the bloom filter with the yellow color?
I think it makes the whole heatmap better.

Again a big thank you for your help :pray:

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Scene);

just put this in simpleInitApp, should work fine. Anyway i dont think its proper for heightmap :slight_smile:

if you need yellow color between green / red, you need again change:

gl_FragColor.rgb = vec3(height/20,1 - height/20,0);

and setup color you need.

I cant say it enough THANK YOU :heart: