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;
and:
vec4 modelSpacePos = vec4(inPosition, 1.0);
gl_Position = TransformWorldViewProjection(modelSpacePos);
texCoord = inTexCoord;
wPosition = TransformWorld(modelSpacePos).xyz;
and:
height = wPosition.y;
in fragment shader:
varying float height;
and:
gl_FragColor.rgb = vec3(height/50,0,0);
(50 value depends)
Yes that’s what i want.
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() {
@Override
public boolean load() {
size = terrainSize;
// clean up data if needed.
if (null != heightData) {
unloadHeightMap();
}
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);
}
}
normalizeTerrain(NORMALIZE_RANGE);
}
return true;
}
};
heightmap.load();
where:
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
Where should i implement the code you wrote?
well i cant do all school project for you, because it would be not fair
- 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);
video:
Thank you
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
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
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
viewPort.addProcessor(fpp);
BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Scene);
bloom.setExposurePower(80);
bloom.setBloomIntensity(3f);
bloom.setDownSamplingFactor(1.5f);
bloom.setBlurScale(2f);
bloom.setExposureCutOff(0);
fpp.addFilter(bloom);
just put this in simpleInitApp, should work fine. Anyway i dont think its proper for heightmap
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