Archived

This topic is now archived and is closed to further replies.

AndreTheGiant

Height map - file format ?

Recommended Posts

AndreTheGiant    329
Im thinking of making a simple height map demo. What is the most popular (ie best) file format to work with? Should I make it so that it will read in a greyscale bitmap? or something else? I noticed that NeHe''s heightmap demo uses .RAW files. Any idea why?

Share this post


Link to post
Share on other sites
markr    1692
A popular one is to use truecolour images with the red field as a height indicator.

If you need more resolution, just use the red & green channels (Fractint supports exporting tgas in this format)

Mark

Share this post


Link to post
Share on other sites
ncsu121978    1344
i would go with an 8-bit gray scale image

i like it RAW

"A soldier is a part of the 1% of the population that keeps the other 99% free" - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA

Share this post


Link to post
Share on other sites
AndreTheGiant    329
Hmm, apparently RAW format doesnt store the dimensions of the image. I would like to be able to use arbitrarily sized images. Any workarounds? Or do I have to hard code the size in the program and enforce that they always use the right dimensions for the images?

Share this post


Link to post
Share on other sites
Fidelio66    164
You are right, raw files are just the data.

Raw files can be opened in paint shop pro, when you do it will ask you the dimensions and bits per pixel. The advantage is that a 256x256 raw file will be 65536 bytes big and can be read in to a block of memory and used straight away.

Share this post


Link to post
Share on other sites
RuneLancer    253
You could create your own format. Or simply alter RAW a little by adding the size at the beginning of the file (as a mini-header).

It would take, maybe... 5 minutes to write a program to accept the image size as input, add a mini header to the file, and have an option to convert it back to RAW by removing the header so that the heightmap can be modified by an other program (like psp or photoshop).

Share this post


Link to post
Share on other sites
AndreTheGiant    329
Yea your right. Its just that I wanted to let users of my program make their own images and use them, so I want to submit them to as little hassle as possible. Of course, I could use a different image format, but I also want to submit me to as little hassle as possible, and I like the simplicity of the RAW format

Share this post


Link to post
Share on other sites
RuneLancer    253
Nice; what technique did you use to generate the heightmap?

It''s pretty hard to give users a simple means of using your program while making things easy on you as well; you''ll have to find a trade-off at some point. Just remember that you only have to code the hard stuff once; users have to deal with the complex get-it-working procedures every time they use it.

Share this post


Link to post
Share on other sites
AndreTheGiant    329
Thanks
Ive never done something like that before, and although I had some problems, it was a lot easier than I expected.

I ended up using the RAW data file format, using greyscale images. Currently I have the values hard coded into the program, so I have to put in an image of the correct size (200 by 200). Im still working on making this better so that you can pass in any image size and still have it work.

I used photoshop and basically just scribbled around until I had a nice bloby picture, without too much contrast from one area to the other (for eg black next to white with no grey in the middle), becuase this would cause super steep, unrealistic looking peaks in the mountains.

My main concern now is that end users may not have a program that creates RAW images. I dont think paint can do it. I cant expect everyone to have photoshop. I could change it to use bitmaps instead, but Im not sure I WANT people using paint anyway. It doesnt have the nice blurring capabilities that photoshop does, so the images will invariably end up with lots of black-next-to-white-with-no-grey-in-the-middle.

Still thinking about stuff I guess. Input is appreciated!

[edited by - AndreTheGiant on March 24, 2004 4:09:22 PM]

Share this post


Link to post
Share on other sites
GroZZleR    820
Look into fractal generation, theres some good tutorials around and it provides nice looking results.

If you''re getting into heightmaps, I strongly recommend Focus on 3D Terrain Programming by Trent Polack (mittens on the boards). Excellent book on the subject.

Share this post


Link to post
Share on other sites
JohnBolton    1372
I use 8-bit grey-scale TGA files. That way a paint-program can load them and save them conveniently and I use my TGA loader code to load them into the game.

Share this post


Link to post
Share on other sites
RuneLancer    253
You might want to give fractal noise and perlin noise a look. Both techniques can generate very nice heightmaps on the fly and could be integrated into your program. Your users wouldn''t have to create the images themselves anymore.

http://www.nbb.cornell.edu/neurobio/land/OldStudentProjects/cs490-94to95/nell/doc/doc.html
An interesting read. No actual techniques, but I guess it can serve as a good primer.

http://freespace.virgin.net/hugo.elias/models/m_perlin.htm
Pretty good source for perlin noise generation.

http://user.cs.tu-berlin.de/~tron/zoo-theorie/alfred/Landscape.htm
Some cool stuff.

http://www.cgg.cvut.cz/vyuka/VIZ/novakp10/doc_eng.html
Some stuff on adding cool things to a map, like rivers and forests, at the end. Probably not the best of ways to do it, but it would serve as a good intro I suppose.

http://collective.valve-erc.com/index.php?doc=1040644009-23694100
Ongoing discussion on the matter?

Share this post


Link to post
Share on other sites