Using 16bit heightmap in material to recreate landscape?


I’m trying to recreate landscape displacement by using the heightmap texture inside a material (the end goal is to use the heightmap data to better match an ocean shader to the landscape).
However there seems to be extreme terracing (or stepping? whatever it might be called :p) which I’m assuming is because the heightmap texture is compressed as 8bit instead of 16.

So I guess the question is… can use a 16bit heightmap inside a material?

I have tried using the “Displacementmap (8/16bit)” option under the compression settings (since this sounds like it’s the only format that supports 16bit) but then the texture goes completely white.

Any ideas or advice will be greatly appreciated :slight_smile:

For that you will need to use floatHDR format. But depending on the world size of the heightmap you may still experience some light stepping artifacts due to GPU precision.

I actually used the same technique for the kite demo so that any meshes on the terrain had a grass transition before they hit the terrain. This ended up only working if the gradient was fairly large (~1 meter or so with modulation using heightmaps to sharpen) since the map had such a huge Z range. The blend modulation helped to break up the artifacts but there were still places where it didn’t quite work as expected.

I also used to so that lakes/rivers automatically got a rock edge where they intersected with the terrain. In that case the artifacts were much less noticeable because I used the rock/pebble heightmap to break it up and that pattern was so high frequency that it dominated any quantization artifacts.

technically you could probably get by with less than HDR if your landscape has a fairly constrained z range. lets say your z range is 255 meters… with 8 bit you will be able to represent ‘terraces’ 1 meter high and nothing more.

Hi there, and sorry for off topic but didn’t know that’s doable. Can you please give me a hint where exactly that’s done so I can take a look at the setup?

in the Kite demo it is on all of the river and lake materials and a few rocks. I don’t have the kite demo installed right now to go get a screenshot showing where it is. All I have is old art meeting images like this:


That was in debug mode showing the limits of the precision. The ‘steps’ are around 1 meter tall here and we only used a 2048 size texture to represent the entire terrain of 10km x 10 km. So the ‘full’ res of the whole map would be 16k so this is using quite a downsized map.

And here it is enabled:


A new technique that we are using now (but not at the time of kite demo) is to use Dither Temporal AA with a combination of constant and heightmap scaling to give blurry intersections. I recommend you try that before spending too much time on this blending stuff since IMO its far easier and looks almost as good.

Thanks Ryan! HDR compression did the trick, no more stepping :slight_smile: the technique adds about ~50 additional instructions to my shader, not bad at all… I think I will be using this a lot in the future.
Here is the result link

I didn’t know kite demo used this technique, it looks like it works very well for rocks.

Could you give us some example using Dither Temporal AA? sounds pretty interesting :slight_smile:

Chiming in 3 years later here: With shaders in plugins, perhaps we could get direct access to the landscapes heightmap and expose it as a node (you’d specify the landscape actor in it).