game engine heightmap conversion references

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
longpinkytoes
Posts: 2
Joined: 2018-03-08T21:11:01-07:00
Authentication code: 1152

game engine heightmap conversion references

Post by longpinkytoes »

although gimp 2.9.8 (march '18) is now capable of exporting gray 16-bit unsigned images for heightmaps,
the only options given on export are save as rgb or rgb planar. this seems to leave a lot of slack for imagemagick.

at the moment: Unity, Unreal, Cry, and for non-commercial learning purposes - Creation
are all free to develop games on, and to my best googling efforts, all require the same image format.

i would really like to see this become a series of posts listing the optimal imagemagick commands
to tailor an image recently generated from noise or imagination, for import into various game engines.

by no means should the list of engines be limited to those above, since hopefully google will reel in
disoriented game devs from every corner of the internet, all hoping to import a map and progress to page 2.
longpinkytoes
Posts: 2
Joined: 2018-03-08T21:11:01-07:00
Authentication code: 1152

Re: game engine heightmap conversion references

Post by longpinkytoes »

three years ago but seems as good a jump-off point as any... [cryengine]
[sozvyezdami.wordpress.com]

don@serebryanya:/tmp$ file x.png
x.png: PNG image data, 512 x 512, 8-bit/color RGBA, non-interlaced
don@serebryanya:/tmp$ convert x.png -depth 16 x.gray
don@serebryanya:/tmp$ mv x.gray x.raw

in case the game engine import doesn't give little/big endian options,
adding --endian lsb or --endian msb will force the proper order.

imagemagick gurus please confirm/deny - day 1 user here. :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: game engine heightmap conversion references

Post by fmw42 »

I know nothing about game image formats. But if you want a 16-bit grayscale raw image with .raw suffix, you can do the following so that you do not have to rename the file.

Code: Select all

convert x.png -colorspace gray -depth 16 GRAY:x.raw
I have added -colorspace gray, since you are starting with a color image. If it works for your game systems without the -colorspace gray, then remove it.

If you want a color image, then you can do

Code: Select all

convert x.png -depth 16 RGB:x.raw
or if there is an alpha channel, then

Code: Select all

convert x.png -depth 16 RGBA:x.raw

See the GRAY and RGB/RGBA formats at https://www.imagemagick.org/script/form ... #supported
Post Reply