Is there a way to make topographic maps of your terrain in UE4?

Hi, is there a way to create a topographic map of a terrain made from a heightmap? (topographic being a map made of wiggly lines, each set of lines representing a height).
I would use it as the game’s mini-map.
I feel like there’s probably a way to ‘fake it’ using a texture that intersects through the terrain?
-thanks.

1 Like

Yes, this is not hard. You can get “world coordinate” as a parameter in the material.
You can then multiply it by 0.001, call fmod(1), and then do a lerp between black and green (or whatever underlying color) over range 0 == black, 0.01 == green (and the rest, also green. Output this as color for the terrain.

What’s going to be tricky is rendering the topographic map to the scenecaputercomponent2d that renders the terrain, but render … not that, to terrain, for the main camera/view. I can’t think off-hand on how to do it – possibly use the render-object-set functionality that might not be blueprint exposed. Maybe with a parameter group to switch between “render for screen” and “render for map” – after all, you may want the full terrain texture underneath the contour lines.

NOTE: if the terrain happens to be flat, right at the height that gets striped black, then there will be a larger, black, area. The gamedev solution is "raise the terrain a little when this happens. It’s actually a hard problem – even in image space, you can’t just “shrink” it, because you don’t know how wide that area might be. Might be very wide. If that’s absolutely not acceptable, then you’ll have to instead procedurally walk your terrain, and put spline points where you want the lines, and do a marching-cubes kind of deal to do height following.

2 Likes

Wait… if you already have the heightmap, you already have the height data, so there’s no need to render anything, just use the heightmap directly. Also, considering the terrain won’t be changing during the game, you don’t want to be rendering it in realtime to a capture, either, just pan a texture.

The math jwatte said is still the same, though. You just work off the heightmap rather than world coordinates.

1 Like