Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Converting DEM (or other raster format) to RAW for import into Unity
gdal_translate -ot UInt16 -scale -of ENVI -outsize 1025 1025 Seattle_16Int.tif seattle_heightmap.raw
-of ENVI means it will write out RAW
This works fine. However, importing this .raw file into Unity produces an Vertically inverted terrain.
I opened with Photoshop CS, then did Image > Flip Vertical.
“Save As” Photoshop RAW. Options were blank, but saving worked.
Loaded into Unity as a terrain setting. Then manually set the Terrain height to 75, which when walking around seems right.
—Clipping Mars DTM (Using BBOX from QGIS to make the output RAW file a sqaure so as not to distort)
gdal_translate -ot UInt16 -scale -of ENVI -outsize 1025 1025 -projwin -2536.49776765 2965965.13578 795.125518636 2963086.69294 /Users/ryanwhitley/Documents/UnityProjects/ImportDEM/Data/Mars/DTEEC_025366_2305_025498_2305_A01.IMG /Users/ryanwhitley/Documents/UnityProjects/ImportDEM/Data/Mars/Mars_Crater_Clipped.raw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment