Thread: Generate landscape using openGL

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    31

    Generate landscape using openGL

    Hi, I am trying to generate a landscape and was told to use mid point displacement algorithm, can someone please tell me how it works? thanks
    'The bigger they are, the harder they fall' ~Yang

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    There are several websites on the net that deal with this as well as a plethora of other terrain generation algos. Google it and see.


    But I don't proceduraly generate landscapes. They are too time consuming and don't ever give me what I want.

    My advice is to get a terrain generation program like Wilbur (google it...again) and let it generate for you. Greyscale it and load into a paint program and smooth the map a couple of times. Save the file in raw format and then extract the values by loading the map. At run-time...scale the values and store in a revised heightmap. This way the values are pre-scaled and you do not have to do a MUL every time you render - or you could pre-compute the triangle mesh and wouldn't have to worry about this.

    Another thing you can do is fire up photoshop or paint shop pro or whatever. Grey scale the image and use the paint brush or spray tool to 'dab' blots of black and white to the image. Remember that light values (255,255,255) will be higher than dark values. Light=high, dark=low.

    The final value for any cell is (R+G+B)/3 or if you wish (R+G+B+A)/3 or you could do some type of alpha blend on it. You can blend several textures together to create very good terrains.
    There is an article on www.flipcode.com for doing exactly this.

    Another method is to download realtime DEM data from the United States Geological Survey and scale it to suit your needs. DEM data is stored in a RAW format and so some of the files will be extremely large.

    For all your heightmaps you should use values from 0 to 65535 or -32768 to +32767 (short int, unsigned short int). This gives a much broader elevation range than the BYTE (0 to 256, -128 to +127). Store the image as bytes and scale it with a magnification factor.

    Working with terrains is a lot of fun and you can make some very good looking ones with low-cost tools.

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Try this tutorial to generate the terrain.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Thanks X!!!!!


    That's what I was going to post here but I lost the link and I didn't print the site out like I thought I did.

    All of my post comes from that exact same link.

    ...now I'll add it again to my bookmarks.



Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM