Raw heightmap formats accepted for level import?

I’m wanting to create a heightmap from a custom data source that is compatible with UE4’s import but I haven’t found anything that indicates what RAW format(s) it actually accepts. From what I’ve read there are almost a dozen different formats and its hit or miss whether or not they have the RAW extension. I know it needs to be 16 bit grayscale but what I really need is a link to a spec for the file format or at least the specific variation expected. Oddly if I just store save the 16 bit pixels only in a file and call it .RAW it seems to not complain, but it also doesn’t look right. I tried the PNG route but trying to create the proper file from source data in grayscale using GDI+ (windose) but you can only generate from an array using RGB and have to convert to grayscale.

Anyone have a link for the RAW file format spec?

Also curious if the umap file formats are described anywhere as I might end up doing a direct conversion later on to save production folks conversion headaches. Haven’t run into it in the unreal documentation yet. Perhaps there is a way using the UE4 api to generate the level definition files?

what are you trying to do exactly? You are making very little sense and meshing together incompatible data sets.

First of, the format is grayscale 16bit Unsigned.
this means values go from 0 to 65535 (where as signed is ±65535/2)

the values mean
0 being black, the other number being white.

on a hieghtmap, therefore, 65535/2 is the approximate “center”.
In a level where you import the heighrmap. This value will be close to Z 0.
Close. Because the value for 16bit is Integer, so you do not have a possibility of setting the exact .5 manually.

In RGB, while black is 0 and remains 0. White or 65535 is actually scaled to a max of 255.

if you use translated RGB values into a 16bit file you get an error margin of
Meaning bit values not multiple of 255 make no sense or are compromised in RGB.

Think our mid point from before, which is now 255/2 in rgb.
If you multiply that result by the ratio, you get a different bit16 number then it should be.
ergo, the data is compromised.
Meaning elevations will almost never look right. With the exceptions of 0, and 255.

Now, therefore, if you want to add data into the engine to match scientific data, you need to stick to the 16bit unsigned int format all the way through - or suffer data loss when you approximate an RBG value into it.

as far as the file format so you can hex edit your own, I would suggest just looking up how to write a PNG in native C.

Or using a drawing program that natively supports 16bit. Krita to name one i have found just recently.

As far as raw format goes. The rules are the same, but the eginen exports PNGs, and they work overall better for import as well, so I would stick with them.

I appreciate the long response. I was aware of most of what you shared except where the zero-point was, good info that I didn’t get out of the docs. The end of your response touched on my question (sorry, I did ramble a bit) where I wanted to know specifically the file format that the importer was expecting for files with the RAW extension. PNG is being avoided and is a long, unrelated drawn out story but I’m not concerned about what the engine is exporting because I’m trying to get source terrain data into the system, not extract it.

If you assume the input data is 10px X 10px for vertices (using a simple example) and I pack it into a raw file as 200 bytes (16bits * 10 * 10) is that incorrect? Its not barking at me and it is reading the dimensions properly but it doesn’t really look right either - but that I still need to confirm with the possibility of rotation and scaling being off. It do wonder though if you were dealing with a non-square heightmap (assuming it supports that) how would that need to be encoded into the file.

The goal is that I have extensive source terrain information already albeit at a much lower resolution that I want to be able to translate into UE4 but the heightmap section sizes are not boundary compatible with UE4 import options (so I’m looking at having to extrapolate either prior to generating my heightmap, or having UE4 do it for me somehow). The tool I have already has height data in a 2D array that I just want to write to a file (which I have as described above, simplest to just use raw since its already in that format). Thanks again for the insight.

I’m down a similar rabbit hole but much simpler in nature.
Why don’t you try something like Qgis to visualize and re-export the data?
I don’t really have more info then that.

Re the PNG format. you will be forced into it when having to deal with files above 10,000 pixels.
Also they import fine.
can’t say the same for the raw format, but if it works for you then I suppose they work just as well.

It occurred to me that I neglected to share my conclusions from this original question. The RAW format is indeed supported in the form I outlined above and I found a good reference for Z-scaling is here (https://docs.unrealengine.com/en-US/…ide/index.html) I just missed it.

I have the same initial question: What fileformat - or more specifik . what are the exprot setting in gimp ?
The link frisbone sends at the end is just saying you can use raw and r16 and png. But at what formats settings???
Im making a low land export, scaling for 0-10 meters. So first I tryed to cook a displacement map in blender using 0-15 meters in for the range of 0 - 10 meters. it cainda works when I in UE use a Z cale of the heightmap: 1.953125 with a .png
I just looks off. so…
I tryed to make a heightmap export from blender rendered in the range of -256 to 255,992 m, qiving me an UE import z scale = 100 - standard format
The big problem is now the 16 bit png range is too limited. I need a 32bit format. Hench the raw format question
When i cook a gimp raw export of a 32 bit .exr heightmap file, UE messes up the map dimention. Originaly the file was 1009x1009 but UE sees it as 1009 x 2018
Gimp is giving me the options:
Type RGB to store:
(x) Standard R,G,B
( ) Plan (RRR,GGG,BBB)
Type RGB to save:
(x) R,G,B (normal)
( ) B;G;R;X (BMP-style)

As firsbone initialy asks, what setting / format of raw and r16 does UE like - or whar program can produce the right format

To make heightmap in blender I used this super cool procedure, from “Default Cube”: Bake PERFECT Displacement Maps (with blender) - YouTube