Zylann / godot_heightmap_plugin

HeightMap terrain for Godot implemented in GDScript
Other
1.77k stars 160 forks source link

export terrain as obj/heightmap as image #82

Open ThunderFD opened 5 years ago

ThunderFD commented 5 years ago

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

Zylann commented 5 years ago

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.

Calinou commented 4 years ago

@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).

Zylann commented 4 years ago

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

MJacred commented 1 year ago

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