Hello all,

I’m generating a terrain through an array with the values for a gray scale image. So here I’m sure the range of values is from 0 to 255.

[java]public float[] convertBufferedImageToArray() {

int imageWidth = heightMap.getWidth();

int imageHeight = heightMap.getHeight();

float array[] = new float[imageWidth * imageHeight];

int[] dataBuffInt = heightMap.getRGB(0, 0, imageWidth, imageHeight, null, 0, imageWidth);

float average;

for (int i = 0; i < dataBuffInt.length; i++) {

average = (dataBuffInt* >> 16) & 0xFF; // red
average += (dataBuffInt*

*>> 8 ) & 0xFF ; // green average += (dataBuffInt*

*>> 0) & 0xFF; // blue average = average / 3f; array**= average; } return array; }[/java] Then the terrain generation algorithm kicks in. I’ve looked at the jME3 code. To me it seemed that the values stay the same, since I don’t provide scale factor at the constructor (=> it’s being multiplied by the unitary vector). But there is probably a lot going on here that I have no idea of, so I have no idea what the range of values here might be. Also I move the terrain and set the scale to one: [java]terrain.setLocalTranslation(0, -300, 0); terrain.setLocalScale(1f, 1f, 1f);[/java] And finally we arrive at the shaders. In the Vertex Shader, I’m filling the gl_Position the usual way: [java]void main(){ position = g_WorldMatrix * vec4(inPosition, 0.0); vec4 pos = vec4(inPosition, 1.0); gl_Position = g_WorldViewProjectionMatrix * pos;[/java] In the Fragment Shader, I’m taking gl_Position.y as the height of things (example: how tall a mountain is) and doing my calculations as if this values still are from 0 to 255. I’m almost sure I can’t just assume that.*

- What are the transformations that I’m missing?

- What is the range of values in the Fragment Shader?

*Is the gl_Position.y the variable that I’m looking for for this?*