Archived

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

Ekim_Gram

I need help understanding height mapping

Recommended Posts

I think I finally understand it but I''m not too sure of it myself so I need somebody to clarify this up for me. To get a height map, you use a gray scale model which is just a bitmap (or any other format) that has different shades of gray (a 24 bit grayscale would have ranges from 0-255) right? So then you draw the lines with GL_TRIANGLE_STRIP and they you add the textures? Is that what it is? Did I miss anything?
There''s no town drunk here, we all take turns. Velocity Gaming Force

Share this post


Link to post
Share on other sites
Well, first off, your typical height map will be 8-bit since there are only typically 256 distinct shades of gray (including black and white) available.

GL_TRIANGLE_STRIP produces triangles, as its name says. You will need to assign appropriate texture coordinates to each vertex for the whole landscape to have the texture properly stretched across it.

We can''t really tell if you''ve missed anything else until you code it and show us the code so we can point out specific oversights or mistakes.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

Share this post


Link to post
Share on other sites
If it helps, I''ve been learning OpenGL from OpenGL Game Programming. I read through the explanation of what you do to get everything done before you code it. I understand the code but I didn''t understand the concept. So, with the 256 shades of gray at your disposal, you decide the height of the terrain depending on the shade of gray. With 0 being black and 256 being white (or do I have them mixed up?), the lower the number the lower the terrain leve. Another question is, how would you go about making a grayscale? Paint?



There''s no town drunk here, we all take turns.
Velocity Gaming Force

Share this post


Link to post
Share on other sites
Photoshop using the clouds plugin. Beautiful random height maps in a second!!! lol

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
quote:

So, with the 256 shades of gray at your disposal, you decide the height of the terrain depending on the shade of gray. With 0 being black and 256 being white (or do I have them mixed up?)


Thats correct. And no you dont have them mixed up.

quote:

how would you go about making a grayscale? Paint?



Yeah, MSPaint would do, or any other imaging program (Photoshop, Paint Shop Pro etc.) that outputs the format you want to use (e.g BMP)

[edit]
PS: If you want any more help theres a tutorial on NeHe.
[/edit]
Hyperdev

"To err is human, to really mess up requires a computer"


[edited by - Lukerd on August 5, 2003 8:38:15 PM]

Share this post


Link to post
Share on other sites
I have found that using Photoshop + Clouds effect + .RAW output file makes for very easy terrain. The raw format is pure binary unsigned chars in order left-right then top-bottom. There are no headers or anything, just start reading. This works well if you have a predefined height-map size. Otherwise, just tell how many bytes of header you would like to Photoshop to insert at the beggening of the file so you can store your dimmensions in the file or any other map data you might want to include for your purposes.

BTW, seems as if you don't understand that YOU must read in the image file, whatever the format, create verticies/indicies, then let your API do the rest, (mostly). your API will only render for you... not the making of the indicies/verticies. Maybe you completely understand and find me insulting by thinking other wise, in which case I'm sorry, you didn't make it to clear from your posts.

Hope I've helped!

Dwiel

For all in need of free hosting for pics/etc:
upload to ftp location: dwiel.no-ip.com user/pass = FreeHostedPics/gamedev
Your files will be available on the inet immediately at http://dwiel.no-ip.com/~FreeHostedPics/
Feel Free to create a folder there for your self!


[edited by - Tazzel3d on August 5, 2003 8:48:41 PM]

[edited by - Tazzel3d on August 5, 2003 8:50:39 PM]

Share this post


Link to post
Share on other sites
the problem with using a byte for teh height is that you only get 256 discrete height values, which can result in horrible looking "steps" in your terrain...i used floats and a fractal terrain generation algo, and my terrain is smooth++

Share this post


Link to post
Share on other sites
Well, a heightmap can be anything really. Doesn''t just have to be grayscale. You can pack alot of info into an RGB bitmap. Use the R&G bytes to store the height if you want more than 256 discrete values. Then you can use the B to store other info, perhaps a model to be put at that mesh. vertex of (25, 255, 187) would use the 25, 255 to determine the height, and then put model 187 (school building) at that vertex. You can use the data in a heightmap for anything you want. The more info you pack in the obviously harder it will be to generate the data, but if it was easy, it wouldn''t be worth doing.

Share this post


Link to post
Share on other sites
Also, look into using Perlin Noise to make your heightmaps. WELL worth it. Allows you to only need a handful of variables and can generate infinite terrain proceduraly. All I need now is the following parameters: frequency, amplitude, persistance, offset, seed. Seed is just a random-number seed I use to generate my initial list of primes for the pseudo-random generator. What this allows me to do, perfect for networked games, is pass you those 5 numbers and you get the same random infinite terrain that I will have. Saves on bandwidth (much easier to send you 5 numbers than an entire heightmap even if it is an 8bit greyscale) and is very slick when it is done. Also, makes changing/updating the terrain trivial when done over a network. Send you the new 5 numbers, you''re done.

Share this post


Link to post
Share on other sites
quote:
Original post by Lukerd
quote:

So, with the 256 shades of gray at your disposal, you decide the height of the terrain depending on the shade of gray. With 0 being black and 256 being white (or do I have them mixed up?)

Thats correct. And no you dont have them mixed up.



Not precisely: 255 is white. You can''t represent the number 256 with 8 bits, only 256 values (since they''re inclusive of 0).

Share this post


Link to post
Share on other sites