Inverted Height Maps Have Stopped Working

I made some 3d audio Spectrograms using Babylon.js and Audacity sound editor. The tutorial for these is here together with the HTML, textures and sound files.

An Audacity user noticed that they had all stopped working and traced the problem to this line:

var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", heightmap, 500, 264, 1000, 40, -40, scene, false);

Note that the minimum height of 40 is larger than the maximum height of -40. This is because the grayscale height texture has darker shades = higher elevations. However, it worked fine for several models back in March 2018.

He managed to get the model working by swapping the minimum and maximum heights and inverting the grayscale texture. The model fails if minimum is larger than maximum height.

Is this a permanent change or a glitch that slipped thru? Sorry that I can’t tell you exactly when it changed except it was some time after 12mar18.

Do you mind reproducing in the Playground?
I will fix that for you then

I couldn’t get it to run in Playground but I found I could replicate the problem using the “Light projected texture” example.
The ground mesh is given by this line
var ground = BABYLON.Mesh.CreateGroundFromHeightMap(“ground”, “textures/heightMap.png”, 100, 100, 100, 0, 10, scene, false);
If you swap 0,10 for 10,0 the model fails which is the same problem I have.

So this is what you see right?
https://www.babylonjs-playground.com/#CQNGRK#25

What would you expect? To get inverted values (like darker = higher) if max < min?

That’s what I see all right.

What would you expect? To get inverted values (like darker = higher) if max < min?

That’s right. That’s the way Babylon.js used to work last year and is what I based my models on.

Fixed!

Great stuff and many thanks. My models still don’t work and neither do the Playground inverted examples. Do I need to wait until your changes are officially released? (I don’t understand how GitHub works)

No worries. It will be merged today and available in a few hours for you to test

Many thanks again. My spectrograms are working again at these locations

Robin
and
Seagulls

3 Likes

yeah!

Wooo my iPhone did not like those scenes :crazy_face:. It crashed twice trying to view it and my phone had to restart. Never seen that before.

Let me guess? iPhone?

1 Like

6s to be specific.

1 Like

hahaha …Apple and the web…