HeightMap png question

Hi,

I’ve been a programmer for over 20 years, but I am brand spankin new to 3d graphics. I have searched for the answer to this on the forum here, but I cannot find an answer, probably due to the number of returns for a heightmap search.

What the heck does a height map contain???

What size should it be?
does each pixel represent a scaled portion of the terrain generated?
Does the color of each pixel represent the scaled height of the terrain?
Does it have to be square?
Where can I find an example of a Panda3D heightmap?

Thanx for your help :slight_smile:

It’s called GeoMipTerrain.

One of forums search results :
discourse.panda3d.org/viewtopic.php?t=7084

Don’t overlook the manual page Geometrical MipMapping.

Your image should be a power of 2 plus one in each dimension, but doesn’t have to be square. It’s a grayscale image whose brightness corresponds to height. If you need more precision you can make it a color image and use R, G, B as the separate bytes of the height, but that’s probably more trouble than it’s worth.

David

thanx David,

Yea, I was doing the tutorial, i shouldn’t speed read :slight_smile: but I got it now, Luminance or a power of 2, and size doesn’t matter (oh I so want to say a bad joke here!)

Got it now :mrgreen:

I’m a little confused by what you say, because “power of 2 plus 1” refers to the size of the image, and this does matter.

A power of two is any number of the series 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, …

A “power of two plus 1” is a number of the series 2, 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, …

Your image must be a power of two plus 1 in each dimension. This means it may be 129 x 129, or 257 x 257, or 129 x 513, or 257 x 1025. It doesn’t have to be square, which means the x and y values don’t have to be the same thing (257 x 1025 is not square, but each dimension is a power of 2 plus 1).

David

Um, actually, its simpler than that;
using the following, you can make a 16 bit grayscale image.

myImage = PNMImage(xsize,ysize)
myImage.makeGrayscale()
myImage.setMaxval( (2<<16)-1 )

(the important line, obviously, is the third)

I seriously recommend a 16 bit grayscale image, it makes a very notable difference if you have even moderatly uneven terrain.

(i spent many days trying to figure out why my perlin noise algorithm was producing such boring terrain, and why if i tried to compensate it would cause retro style height banding)

I’m not afraid to admit my stupidity :frowning: I was thinking that night I was looking at it that it was the luminance that was a power of 2 + 1 (now that would be a pretty flat landscape!). When I’m tired I read fast and fill in the blanks in my head. After a nights sleep it all set in, thanx for you help :slight_smile: And thanx fynn for your comments, I’ll definitely keep that in mind when I start getting more advanced. I am looking to generate random terrain at some point also.

My next thing after that will be dynamically loading and free-ing terrain as the camera moves to different areas. So that I can have huge terrain without loading it all in.

for storing high (vertical-)resolution heightmaps there are at least 2 supported image formats .ppm with 16bit per color-channel and .pgm in ascii-mode (which is actually smaller for less-than-5-decimal-digit-numbers if you just want gray) with any resolution you like (propably even there are limits)
.pgm,.ppm (german entries are better: .pgm, .ppm)

.PNG supports 16-bits-per-channel images as well.

.png offers compression and so you should better use this instead of .ppm - ascii-pgm stays an option since it offers unlimited resolution but if not compressed can be quite large.

actually you could also use .tiff ith as many bits per channel as you want but no program known supports every tiff, yet…

Can I ask a question here?
Can you export a heightmap with Blender?

This way (dividing) you can at least export some heightmap but its inverse!
on the other hand you can get a good preview…

if you place the camera near enough to the object you can use multiply instead of divide for getting a real linear heightmap ready for use…

remember to switch the camera to ortographic (you dont want perspective now - panda will do that later)

Yes theres a Blender addon images plane i think its called that can convert a heightmap to a terrain, remember google is your friend :smiley:

But Panda is more powerfull in my opinion