Generating .r16 files for use as heightmaps

I have a landscape importing problem I can’t use world machine for. I’m going to map out a small historical railway from the UK, to help make this easier I’ve searched for a heightmap of the UK, which I found, in an ASCII format for GIS programs. The plaintext heightmap is easily parsed so I want to write a little program to read the section I want and output it as an .r16 for unreal.

I couldn’t find much on the format, but as far as I can tell it is just a binary file of 16 bit integers with no header. This gives me enough to just try generating one and see what the results look like but I have some specific questions about how unreal uses it.

What do the integer values correspond to? The height of each of the vertices of the landscape’s mesh in unreal units?

Is there a way to ensure the resulting landscape is to scale? The heightmap I am using is Ordnance Survey’s ‘OS Terrain 50’ raster grid heightmap for GIS programs, the grid describes 50 meter squared square tiles of a certain height in meters, rounded to the nearest 0.1 meter. Making these tiles in a heightmap of points shouldn’t be too hard, but the resulting landscape shouldn’t have 50m spaces between vertices, that’d be ugly as hell and useless for editing into a more natural looking landscape. A better way to put it is probably, how would I work out how big each tile would be in vertices in an unscaled landscape with arbitrary resolution so that they are at least roughly 50 meters squared where 1 uu = 1cm

And finally, this kind of ties into the previous question but does anyone know how world machine treats these files? Ideally the .r16 would be importable into world machine to scale so it can mess with it before importing into unreal.

some things i’ve figured out since this post
landscapes are made of quads, the quads are 1x1 unreal unit, by default the landscape is scaled up 100x, this quad size does not vary by number of quads in a segment. So landscapes are by default the same size in meters as they are in resolution. the biggest possible is 5.6km

all i need to figure out now is how to properly scale the height values

Got this working, here was the soluition, the first half might be useful for anyone generating landscapes externally

Landscapes are made up of quads that are 1uu squared. By default landscapes are scaled 100x so this ends up 1 quad per meter. This is true at any resolution.

As for height, I have no idea why it works but if you take the height as meters, multiply it by 100 (assuming you are using 100x landscape actor scale and 100 uu = 1m) and you get a height that is ~78% smaller than it should be. Simply scale it again by 1.282 and it will just work.

Now say the Esri GRID file uses a cell size of 50 meters, this means that each tile in the grid file is 50x50 quads. Repeating the value 50x will get you a 50 meter line of quads at that height. Repeat the line 50x and you get square tiles set to heights from the data. The maximum size of a landscape is roughly 5.6 km squared, limited by number of components. Do not export more than that when reading a very large GRID file.

Using that, it is simple to convert the plaintext data to something unreal can read. For best results some smoothing should be applied to make it more workable for mappers.

Hi, Draco, I have a similar question as a new UE5 user so I hope you don’t mind me resurrecting this 8 yr old post :slight_smile: I have found a source of GIS data which has a resolution of 1m. I want to import the data to use as a heightmap, but it comes in the ERDAS Imagine, .img, file format. I can open that file and parse it in MATLAB so I can plot it in MATLAB, but can’t find anything that talks about the UE5 .r16 or g16 file formats so I don’t know how to export the data in either one. I see from above that you say it is “a binary file of 16 bit integers with no header”. Have you found it to be that simple? How does UE know the dimension of the data it is supposed to read without a header? Currently I have a 1500 x 1500 array of elevation data. Do I need to truncate that to some value compatible with UE? Thanks for any help in advance, Chris