Back to plugins page
Image to heightmap converter
Released under the GNU LESSER GENERAL PUBLIC LICENSE.
Download Windows version
Download source code
NOTE: Please read the Requirements and Issues and Limitations below before using this utility.
Requirements
- Windows platform
- Microsoft .NET framework 1.1
- DirectX version 9
This utility was a quick and dirty solution to convert heightmaps into AC3D meshes. It's a
small utility with specific requirements (Windows platform, .NET, and DirectX 9).
These requirements exist simply because those were the tools I had on hand in which to
code the project within a short timeframe.
If you're on Windows and are not sure whether you have the Microsoft .Net Framework 1.1 installed,
go to your Control Panel, and double-click the Add or Remove Programs icon.
If Microsoft .NET Framework 1.1 is present, you're in good shape.
Otherwise, you can download .NET Framework 1.1 from Microsoft Windows Update, or you
can get it here.
Similarly for DirectX, to get version 9, visit Microsoft Windows Update.
Sincerest apologies for the number of tools required to support such a simple app.
As mentioned above, it was simply a case of using the tools I had available, and
was not thinking of distributing the app at the time.
Issues and Limitations:
- All images are converted to power of 2 bitmaps prior to import. This is the result of
my use of DirectX to read images rather than using another image loader. WORKAROUND:
If you need a specific size on your heightmap, add a black border to your image to make it a
power of 2 (32, 64, 128, 256, 512, 1024, 2048, 4096, etc) for both width and height. Once
the heightmap is imported, delete the unused surfaces within AC3D. So, for example, if you
have a 25w x 32h image, add a 7 pixel border to make it 32x32, then remove the excess surfaces
from with AC3D.
- Not sure of size limitation for input images. I use the Direct3D reference driver for image loading,
so it should not be hardware-dependent, but I don't know what its maximum size is and it's
been a while since I've done DirectX programming. HOWEVER, if you run into a size limitation,
you're probably creating a mesh that's to large and unwieldy, anyway.
- Not all options on the form are functional. These have been disabled on the form.
- Only reads files in the following formats: bmp, dds, dib, hdr, jpg, pfm, png, ppm, tga
Description
Reads an image file in one of several formats (bmp, dds, dib, hdr, jpg, pfm, png, ppm, tga)
and creates a 3D heightmap with vertices at those points. Useful for importing terrain.
Turns this:
into this:
Installation and Usage
To install, unzip the img2hm.exe to a directory of your choice and execute it. There are
no registry entries or other settings written or altered by this executable.
Upon execution, you may use the following options to import an image.
- Image file (input): An image file that is to be converted into a heightmap.
If this is a grayscale image, the values are taken from the bitmap and written to the
output heightmap. Otherwise, img2hm converts the color value to grayscale. Of course,
your input file is not changed during this process.
- Orientation: NOT AVAILABLE. To change the orientation of an imported
heightmap, simply rotate it within AC3D.
- Position (width): Sets the X axis position of the heightmap in relation to 0,0,0.
- Position (height): Sets the Z axis position of the heightmap in relation to 0,0,0.
- 3D distance between pixels: Each pixel in your input image will be represented as
a vertex in AC3D. Use this value to set the X/Z spacing between vertices.
- Maximum height: There are a maximum of 256 "levels" at which a heightmap can
place vertices along the Y axis. The minimum value is zero. The maximum is the number
you set here. Higher values yield more bumpy/hilly heightmaps.
- Texture span (width): NOT AVAILABLE. To change texture coordinates, use the Texture Coordinate Editor.
- Texture span (height): NOT AVAILABLE. To change texture coordinates, use the Texture Coordinate Editor.
- Output file format: Currently, only AC3D files are exported with this utility.
- Use triangles (instead of quads): By default, a 4 sided surface (quad) is created between each
vertex grid of the heightmap. When dealing with certain peaks and valleys, however, you may find
that polygons with invalid triangulation are created. If this happens, you may wish to create the heightmap
using triangles instead of quads. NOTE: you may also workaround defining *all* surfaces as
triangles by selecting only surfaces with bad triangulation (Edit -> Select surfaces -> with bad triangulation)
and using Surface -> Triangulate (make sure you are in Surface mode).
Once all options are set, click Convert. You will be prompted for an AC3D file to output,
which you may then open or import within AC3D.
NOTE: Start with small images. Images greater than 64x64 will suffer slowdowns within
AC3D due to the sheer size of the vertex and surface data. For example, a 128x128 image will
create a heightmap with 16,384 vertices and 16,129 surfaces (or 32,258 surfaces if using
triangles instead of quads). Experiment to find the sizes that work for you.
Back to plugins page