Thread: Continous LOD Terrain Source... Released!

  1. #1
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640

    Continous LOD Terrain Source... Released!

    Classes ended yesterday, exams don't start for 3 weeks == I actually have time for fun things!

    I put together a simple demo of my Continuous Level of Detail Terrain Renderer and posted the source on my website for your enjoyment. It is an implementation of Roettgers algorithm. You can use the code in your own projects under the terms of the GPL (please understand what this means. if you're not familiar with the GPL or you're unsure, just ask )

    This is more of a source dump rather than some kind of tutorial, as a result... the documentation is sparse and the code is complex. If you really want to know whats going on I suggest you read Roettger's paper on rendering continous level of detail height fields

    I have successfully run this on OSX and Linux. It should theortically run on windows just fine as well. Just have a look at the README for compilation instructions (in particular, note that you have to define the OS at build time as either OSX, LINUX, or WIN32).

    Quote Originally Posted by README

    Continuous Level of Detail Terrain Rendering Demo

    Table of Contents:
    - What this is
    - What this is not
    - HOWTO build (OSX, Linux, windows)
    - Controls
    - Source Code


    What this is:
    A demo showing an implementation of Roettgers terrain
    rendering algorithm. Includes a sample terrain and
    texture (both generated using tools from jeff.bagu.org)
    as well as a sample driver (Main.cpp) which shows
    how to use the terrain class.

    Be sure to try toggling filled and wireframe mode to
    see the algorithm in action!


    What this is not:
    A game engine, a complete rendering engine, or any
    other combination of words which involve "engine"
    without "terrain" :P

    Simple camera movement and collision detection with
    the terrain has been implemented to allow you to
    explore the terrain. But there is no polish or gold
    trim.


    HOWTO build:
    A makefile is included (and is set up for a linux build)
    You need to define one of 3 flags at compiler time to
    specify your target OS. Use either OSX, LINUX, or WIN32
    (ie. -DOSX, -DLINXU, or -DWIN32 as a compile option)

    You will need the GLUT and OpenGL libraries installed.

    For OSX (XCode), simply import the souce files and add
    the GLUT and OpenGL framewords to your project.


    Controls:
    a,s,w,d -- Standard FPS controls (movement)
    mouse -- Look
    PG_UP -- Increase height above terrain
    PG_DN -- Decrease height above terrain

    7,8 -- Toggle fog
    9,0 -- Toggle filled/wireframe rendering


    Source Code:
    The souce code is available for use under the terms
    of the GPL (http://www.gnu.org/licenses/gpl.txt).
    Please leave the License agreement in the source
    files and credit the use of this software. Other
    than that, enjoy!


    (c) Jeff Pound, 2006
    http://jeff.bagu.org
    Download details here: http://jeff.bagu.org


  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Neato! I was hoping to play with procedural textures and chaos theory when I got some free time. Did you attempt to use any "noisy" algorithms to generate your textures?

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    I generate the terrain texture by blending together existing textures. The terrain itself was generated using the fault algorithm. The main focus of this project was not the terrains themselves though, its more about the rendering algo.

    Did you get it running ok? on which platform?

  4. #4
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    I didn't download the source at first, just looked at the pictures and read your notes. After trying to build it using VS, I had to replace #import <windows.h> and #import <GL/glut.h> with #include's (I didn't have it set up to use type libraries).

    I also had to #undef max because of your inline function. I'm not sure where it was finding a max macro though.

    I noticed that it wouldn't build without glut32.lib, and also complains that it can't find glut32.dll when I ran it...are you using both for some reason?

    After all that, I also got a NULL acception. Not sure where/why, but I'll check it out a little later to let ya know!

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    hmmm, interesting. I've never tried to run it on windows so I don't really know. You need to link the glut and and opengl libraries, maybe it needed glut32.dll as well becuase of your project settings.

    As for import vs include, I though I had changed that, (import is a gcc extension). oops!

  6. #6
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Ok, I uploaded 0.7.1 which removes the use of import and changes the max inline function to maxf (which hopefully avoids the conflict).

    As for the NULL exception, :dunno: Works fine on Mac OSX, Fedora Core, and Debian so far.

  7. #7
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Yeah, don't worry about that NULL exception too much. It wasn't able to find the data folder because of the directory structure, but that's ok now. There are some other crashes though...I crashed on Terrain::getHeight. If you go backwards immediately after start up, it should happen.

    I'm seeing pretty low fps...debug won't go above 1, and release hangs out around 45ish. I'm running on a Windows OS btw, GeForce 5900.

  8. #8
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Hmm, i don't get the crash you described on OSX. But thats more related to the demo, and not the rendering algo anyway.

    As for FPS, I get a 200 - 300, with dips down to ~180 on my laptop. (ATI X1600 mobility). You could tune down the amount of visible terrain by changing the scale or the back clip plane. Again this is related to the demo rather than the rendering algo so its a detail I'm not overly worried about

  9. #9
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    [quote]
    Again this is related to the demo rather than the rendering algo so its a detail I'm not overly worried about
    [quote]
    good point. I also changed the black to a pale blue because I thought it was too gloomy lol.

  10. #10
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    499
    It looks very good; I was achieving 90+ framerates on my G5.

    There was only one problem: Some of the triangles would disappear, leaving holes when viewed at certain angles. I don't know whether this is due to the Z buffer, or depth testing, or something else, but it does look a little funny. My gcard = NVIDA GeForce FX 5200.

  11. #11
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    hmm, that doesn't sound so good joe. holes are bad, can you take a screen shot of what your seeing so I can try to reproduce it?

  12. #12
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    499
    This isn't exactly what was happening before, but it's pretty close....

    The first 2 shots are what it looked like at one angle, the second 2 are what it looked like at the other angle.

  13. #13
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    oohhhhhh. What your seeing is just the back clipping plane. This is normal, and is why many games (as well as the demo) use fog. I think 7 or 8 turn fog on/off in the demo.

  14. #14
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    That is the far clip plane as Perspective has stated. But his far clip plane should be way out there since he is using this algo. You could use this algo for a simulator, although I think FS 2004 and all MS uses the geo mip mapping algo.

    FS 2004 achieves some insane viewing distances as have all MS flight sims since the early 90's. Quite impressive.

    How close the fog is in a game will give you a good indication of how well the outdoor portions of the game are coded.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 'Type' Error on Build of Officially Released Source Code
    By Jedi_Mediator in forum C++ Programming
    Replies: 5
    Last Post: 07-07-2008, 05:28 PM
  2. Terrain LOD [Free ScreenShots!!]
    By Perspective in forum Game Programming
    Replies: 14
    Last Post: 03-15-2005, 01:39 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Duke Nukem 3D Source Code Released
    By Daniel in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 04-03-2003, 09:35 PM
  5. Return to Castle Wolfenstein source code released
    By Unregistered in forum Game Programming
    Replies: 1
    Last Post: 04-15-2002, 07:20 PM