Create Contour Lines from a height map

My problem is exactly this. I have a height map of a terrain and I want to create a 2d image or something representing the contour lines from it. Is there any possible way to do this within UE4?

Check this out, Chris explains how he is done the contour lines - https://youtu.be/nqatEfc5w5I?t=6191

floor(heightmap * NUMSTEPS) / NUMSTEPS;
gives you a “sliced” heightmap. Render it to a texture.

You can then use a simple outline algorithm by sampling the new heightmap multiple times and comparing the values to get the lines

I found d it faster to create an actor BP with a screencapture2d and render to a render texture / save result.

Another way might be to take the sine of the absolute world position z coordinate in your material editor, then whenever the result of the sine is larger than some floor value (say, 0.95), use the desired color of your contour line instead of the normal texture. If you want the lines to be spaced out or closer together, multiply the argument of the sine by a number smaller or larger than one, respectively.

You could try this

And the contour palette is just a 512x1 image like this:

contour_lines

You can control the width and color of the lines. You can even make it a color palette to recolor the whole heightmap. Only problem is it uses one of your landscape texture slots (if you’re using UE version < 5 you only get 14ish texture slots in your landscape material).

Here’s what I did with it:

2 Likes