Terrain potential

I asked this question earlier in another post but didn't get an answer. =)

Is there a way to potentially exaggerate the terrain? Maybe even add a slider to increase or decrease it?

The terrain is amazing and very accurate but I think it'd be a cool option to increase it so you could recognize your own local ups and downs from a higher altitude then borderline streetview.

Thank you kindly,

- Adam

Hi Adam, I saw your message before. Sorry I haven’t responded until now…

There’s currently no built-in way to exaggerate terrain, but it can be done by editing the code. Take a look at HeightmapTessellator.js around line 288. That’s where it determines the height. To exaggerate terrain 2x, just multiple that value by 2.0.

Hooking up a slider is more difficult. The height is baked into the terrain tile mesh, so the direct approach is to regenerate the mesh when the exaggeration changes. That’s going to be very expensive. A more workable approach is to modify the vertex shader to apply an exaggeration specified as a uniform. That’s pretty tricky, and likely to lead to precision / jittering problems when zoomed in close. Hopefully you can live with modifying the HeightmapTessellator for now.


Hey Kevin,

Thank you so much for your answer!

I was able to track down line 288:

heightSample = heightSample * heightScale + heightOffset;

But as I’m a novice at javascript, no idea how to multiply this by 2.0. I trust it’s *2 but how exactly do I type it out? Maybe I adjust the heighScale ?

Also, I’m okay with not having a slider, how about maybe creating a button to enable or disable the exaggerated terrain?

Is that something that could be switched on or off in a live cesium viewer or would it need to be adjusted before even loading up cesium?

Thank you again!!!

  • Adam

Oh nice I made it work!

heightSample = heightSample * heightScale *10 + heightOffset;


Okay, now to adjust this in map as a button…


Could I potentially create multiple .js versions of that file with different exaggerations and then load them as per buttons inside of cesium?


  • Adam

That’s pretty close, but you should multiply the offset, too. So something like this will do the trick:

heightSample = heightSample * heightScale + heightOffset;

heightSample *= 10.0;

If you change the multiplier at runtime (no matter how you do it), it will only apply to new terrain tiles loaded after the change. So the simplest thing is to force all the tiles to unload, and then they’ll reload with the new exaggeration. This is what the Terrain Sandcastle example does when you change terrain providers. To see how it works, trace through that code.



While we’re on the topic…

Is there a way to adjust the zoomed map images to be more similar in colour?

Once you start to zoom way in, the detailed maps are gray where higher up they’re green.

Is this on the cesium end or is this just bing’s fault?

You’re the man Kevin.

Thank you,

  • Adam