Internet articles on Heightmap Generation

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Sanshin77
Chaos Rift Regular
Chaos Rift Regular
Posts: 160
Joined: Tue Mar 10, 2009 9:36 am
Current Project: C++/SDL engine, zaActionWizardMagic game
Favorite Gaming Platforms: Xbox 360, Playstation 2, Nintendo DS, mac and PC
Programming Language of Choice: C++

Internet articles on Heightmap Generation

Post by Sanshin77 »

Hi I've been working on a heightmap project for quite some time now, and I have some trouble with creating algorithms for generating varied terrain and smoothing the heightmap...

I don't wanna bore you with all the details of my algorithms, I'm just wondering if anyone could point me to a website where I can learn about this. I haven't gotten into really advanced math in school yet, I'm 16yo. I want to be able to generate varied terrain for game maps in 3D. Note: I'm not making any 3D games, this is for learning-purposes.

So 2 questions:
1. Can I read about smoothing a heightmap somewhere, any site you've used? My smoothing algorithm creates a too blocky result...
2. Is there a pretty easy to understand article somewhere on generating heightmaps? I need to create a method that generates a complete heightmap with varied terrain, based on a single number, so that it will generate the same heightmap If I store this number for later. I've been able to create some decent peaks with my method, but I haven't been able to "randomize" their placement without using random number generators.

If somebody could point me to websites to read about this, or relevant websites to learn relevant math/calculus/whatever, I would be grateful.
Check out videos of my C++ games as well as my "Amateur Game Dev" series over at
My YouTube Channel: http://www.youtube.com/user/Zanchill
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Internet articles on Heightmap Generation

Post by Falco Girgis »

You know, that even though lots of engines have built-in Terrain brushes (like Unity) that generate height maps for you, they all load grayscale bitmaps as heightmaps as well. You could technically make one in paint with black and gray pixels.

As for smoothing algorithms, I haven't really played around with this kind of thing much, so I can't offer any advice.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Internet articles on Heightmap Generation

Post by avansc »

id probablly look into generating a a standard deviation of some sort, and making sure than adjacent points dont exceed that, also probably look at deltas of angles.

im sure if you multiple with some type of inverse of the averages of each of the neighboring points and do that for all points and perhaps do that iterativly you will smooth it out. if you do it enough you'll end up with a flay plane.

you could also tesselate/sub divide the mesh and interpolate the mid points, which would work.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Sanshin77
Chaos Rift Regular
Chaos Rift Regular
Posts: 160
Joined: Tue Mar 10, 2009 9:36 am
Current Project: C++/SDL engine, zaActionWizardMagic game
Favorite Gaming Platforms: Xbox 360, Playstation 2, Nintendo DS, mac and PC
Programming Language of Choice: C++

Re: Internet articles on Heightmap Generation

Post by Sanshin77 »

GyroVorbis wrote:You know, that even though lots of engines have built-in Terrain brushes (like Unity) that generate height maps for you, they all load grayscale bitmaps as heightmaps as well. You could technically make one in paint with black and gray pixels.
Yeah, and my heightmap isn't really that far from a bitmap, its a 2 dimensional array of signed shorts. If I continued this project and started using it with 3D rendering and in games, I would of course find a way to load bitmaps. Algorithms and the idea of (randomly) computer generated content fascinates me and I want to learn more about this stuff, that's it. I've implemented 2D drawing with SDL, but the main reason why I started this was to try/learn about the generation part.
avansc wrote:id probablly look into generating a a standard deviation of some sort, and making sure than adjacent points dont exceed that, also probably look at deltas of angles.

im sure if you multiple with some type of inverse of the averages of each of the neighboring points and do that for all points and perhaps do that iterativly you will smooth it out. if you do it enough you'll end up with a flay plane.

you could also tesselate/sub divide the mesh and interpolate the mid points, which would work.
Thanks, I'll do some googling on the different methods you mentioned and see what I can find. :) :worship:
Check out videos of my C++ games as well as my "Amateur Game Dev" series over at
My YouTube Channel: http://www.youtube.com/user/Zanchill
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Internet articles on Heightmap Generation

Post by Falco Girgis »

Actually, a bitmap is a pretty goddamn simple datatype (that's why the file sizes are so large). With a bit of research (for parsing the header), you could write your own simple bitmap parser without any trouble at all. So then you can populate that 2D array of yours with the bitmap.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Internet articles on Heightmap Generation

Post by eatcomics »

Funny, as the book I've been using, Game Programming with OpenGL, has all this stuff in there :D

its not a bad book, but its very Windows oriented.
Image
Post Reply