godot_heightmap_plugin icon indicating copy to clipboard operation
godot_heightmap_plugin copied to clipboard

export terrain as obj/heightmap as image

Open ThunderFD opened this issue 6 years ago • 4 comments

it would be cool if we could export the terrain mesh as obj and/or export the heightmap as an image

ThunderFD avatar May 30 '19 18:05 ThunderFD

You can generate a mesh of the full terrain, however it will be extremely dense (so not recommended for exported game). I initially added that feature to be able to generate a navmesh, so it doesn't have normal (Godot has no clue what a shader-displaced mesh is when generating a navmesh, among other things...). I could improve it by adding a few more data so that GIProbe can be used too, but keep in mind it is extremely expensive to use this on a large terrain.

Exporting the terrain as image is a bit difficult because there is no image format Godot can save which don't screw up heightmap precision. If you save a greyscale PNG, it will have a 0..255 precision, while the terrain actually needs 0..65536 to be smooth. There was two proposals to support 16-bit PNG in Godot but they were dismissed for other reasons. Mine is still open but core dev doesn't want it https://github.com/godotengine/godot/pull/19497

Using EXR would be an alternative but Godot can't save to that format either, AFAIK (and can't properly load it as single-channel too https://github.com/godotengine/godot/pull/27327#issuecomment-475735082). Someone has to do it I guess.

Zylann avatar Jun 11 '19 15:06 Zylann

@Zylann This should now be feasible in Godot 3.2 and later thanks to Image.save_exr(path) :slightly_smiling_face:

You can open the resulting file using GIMP and save it to a 16-bit PNG if needed (or use ImageMagick to convert it).

Calinou avatar Mar 25 '20 08:03 Calinou

I added EXR export recently, but it bumps on this bug: https://github.com/godotengine/godot/issues/34490

Zylann avatar Mar 25 '20 23:03 Zylann

This would be possible in Godot 4, using FileAccess (see latest comment in #34490)

MJacred avatar Mar 30 '23 11:03 MJacred