Shader variable parsing

    AbstractHeightMap heightmap = new AbstractHeightMap() {
        public boolean load() {
            int terrainSize = 256;
            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 < cords.size(); i++) {
                setHeightAtPoint(cords.get(i).getY(), cords.get(i).getX(), cords.get(i).getZ());
            setHeightAtPoint(200f, 1, 1);
            return true;


    TerrainQuad terrain = new TerrainQuad("asdf", 256, 513, heightmap.getHeightMap());
    Material mat = new Material(assetManager, "Materials/newMat.j3md");

These are my Coordinates heights from cords.get(i).getY()

But my height doesnt seem to change, e.g when i put in 150 instead of cords.get(i).getY()

nvm found my error at normalizeTerrain(NORMALIZE_RANGE);
But my color doesnt change still.

well it did change, you said it turned all red when you add +20 there.

so it means:
+0 -> all green
+20 -> all red

so shader seen difference in height correctly. you just have this difference too low it seems. so like i said you need adjust this 2 lines in shader to match your terrain.

you mean these two line ?

height = wPosition.y + 20.0;

gl_FragColor.rgb = vec3(height/20.0 , 1.0 - height/20.0 ,0.0);

yes, if you will set 20.0 values here correctly, it will work for sure - if your terrain have mountains trully.

you know what it do right?

gl_FragColor set color for certain pixel.

so you can check a lot of things like for example:

height = wPosition.y;
gl_FragColor.rgb = vec3(height, 0,0 ,0.0);

and see if its all black everywhere or is it red somewhere.

etc etc etc


this is what happens when i adjust the two lines.
Are these even real “mountains”?

this lines do not affect mountains, just a color. Your cords.get(i).getY(), cords.get(i).getX() make this “mountains”

“when i adjust the two lines.” - well, again you did not show how you adjust it.

height = wPosition.y +20.0;

gl_FragColor.rgb = vec3(height/33.0 , 1.0 - height/33.0 ,0.0);

33 = highest point.

well definetly something is wrong with it, because since you said your terrain lowest value is in (0,0,0) (box that was in middle) this should be almost RED.


height = wPosition.y;
gl_FragColor.rgb = vec3(height , 0.0, 0.0);

(ofc this 2 lines should be in 2 files separatly)
and show me result.

Its just a black screen

what about

gl_FragColor.rgb = vec3(height * 100 , 0.0, 0.0);


ok, lets try something else.

can you try use some default JME Terrain heightmap? (image one)

just heightmap, no material.