Terrain Feedback

By Shamus Posted Thursday Feb 23, 2006

Filed under: Programming 27 comments

MAKE linked to my terrain project and since then a few people have expressed interest in the code. I’m not sure why this is catching on now. I tried putting the story on digg a few days ago and it was more or less ignored. Go figure.

Anyway, I’ll go over the project and will probably be releasing the code this weekend. If anyone else is interested, just drop a note in the comments. Thanks.

UPDATE 2/25/2006: I have now released the source code.

 


From The Archives:
 

27 thoughts on “Terrain Feedback

  1. Awesome read from start to finish! Thanks for sharing. Even as a non-coder, I found it very stimulating.

  2. I’ll forward the URL to my coding friends. I’m sure they’ll get more out of it than I did.

  3. Bitwize says:

    Yep, another Make viewer here.

    Your thought process thru each step is tight and logical.
    That’s a very high-quality tut, and makes captivating reading..
    ..a big “Bring It On!” for a Google paid authoring system!!
    (yeah, and a GooPay system would be neat too ;O)

    Sure, any code would be great. Particularly the early poly stuff.
    Thankyou for the presentation and ideas Shamus.

  4. Are you ever going to release the source code for this under an open source license?

  5. Michael says:

    This was really interesting to read. I have always been interested in programming in 3D, and your documentation of building a 3D engine was a very good general introduction to this. I hope you elaborate on (and document) your current engine at some point in the future.

  6. Nic says:

    That’s an *awesome* tutorial, the most engaging one I’ve ever read. Thanks!

  7. Emil Albu says:

    Hy.

    It’s really nice that you showed us the step by step process of building a 3d engine. Now i’m starting to understand just how hard it is to make a game engine, specially one that works well on older systems too.

    I’d like to see the source code, and as somebody else said before, a GNU or other type of open source system would be the nicest way to go.

    BTW, if you do post the source, and you still have the older versions, it would be nice to see also the code in it’s different stages, to see just how each modification you’ve documented is reflected in the code (i believe a lot of people would learn quite a few things from it).

    Thanx for the documentation, it was really fun to read it.

  8. Hawk says:

    Very nice walkthrough. As a programmer, I saw alot of the issues you had comming, but then I’m sure you did too :). I’d be interested to know more about the excess polygons on the corners of your ramp example and what the bug was leading up to this. Was it that you were classifying the edge of the map as a elevation change perhaps?

    I do very little graphics programming and would be interested in doing something like this and documenting it … Reminds me of a “geek night” a friend of mine and I used to have in which we’d explore differient ways to solve problems, usually graphics in nature. We wrote a neat-o flame generator in an evening. Nothing nearly this complex, but fun none the less.

    Anyway, thanks again.

  9. Hawk says:

    Oh, BTW, you’ve been metafiltered … Probably explains the increase in traffic.

    http://metafilter.com

  10. Shamus says:

    I'd be interested to know more about the excess polygons on the corners of your ramp example and what the bug was leading up to this. Was it that you were classifying the edge of the map as a elevation change perhaps?

    Wow. I never expected so much interested in the code at all, much less the interest in the old, buggier versions of it. Let me think:

    The ramp stuff was a few weeks ago, but if I remember right there were several problems that led to excess polygons on the edges:

    1. My input data was a bit “jaggy”. I was smoothing it so I didn’t have thousands of little pitcher’s mounds everywhere. This smoothing was not being done along the edges, which made them more jagged than the rest of the terrain.

    2. When comparing elevations (like: hey, are these two points very far apart vertically?) I was incorrectly wrapping the values, so that the points near one edge were being compared to the elevations of points on the opposite side of the map. My first map tiled (the edges matched) so I didn’t notice this until later in the project when I started using a different input image for the terrain.

    3. The “east” and “south” edges of the terrain were not being cleared between updates. So, once one of those edge points was marked “this point is important and should be included in the final mesh”, it would forever stay in use. If you moved far away from that edge, it would retain its high level of detail.

    4. At one point I messed up the image used to generate the terrain. I had a little black line on the edge of the image, which made this cliff. You can see this in action in Part 6, in the second section where I lower the polygon count. Notice how the distant corner of the map seems to retain a lot of detail compared to the other parts? On the back side of that hill is a deep gouge / cliff that pushed the local level of detail higher than it should be.

  11. foobario says:

    If you have the interim code steps I think it would be a great companion piece to your already great writeup. I’m an engineer, some programming experience but I’m not a programmer, and looking over completed source code doesn’t do much for me. Being able to see WHY a change was made would be incredibly useful.

  12. Shamus says:

    Sadly, I did not make incremental code backups. The final source should be available later today.

  13. Shamus says:

    And so it is. You can now get the source.

    And now that this thread has expanded above twelve entries…

    I am wondering how high my dice-rolling script goes. I forget. When I wrote it, I didn’t expect to get a dozen comments on just one post. Hmmmm…. I better check into that.

    1. WJS says:

      Hee-hee! “Didn’t expect to get a dozen comments on one post”? That’s hilarious in hindsight, considering that once the site took off, some posts got hundreds.

  14. Yasin says:

    Great walkthrough!

    Just a thanks for making the material available to us and a general “hey – I read this too” shout.

  15. Anastasios says:

    Now that was a very nice go-thru of many of the problems in terrain rendering and potential solutions; very informative and educational indeed. I doubt if I have ever read anything better on this subject and from the programmer’s prespective I give you my credits for making such a task look easy to the readers! Keep up the good work!

  16. Andrea says:

    Hei ! Good work ! Compliments !!!

    I started a similar project 2 years ago in Delphi …. now I use Torque for a new project !
    I have download your source code for study and learn new features for my old project ….
    Thanks for this work !

    if you want visit my website ! ;-)

    Bye

    Andrea

  17. Mario says:

    Greetings,

    Very interesting. I particularly liked your progressive analysis of the problem. When trying to access the download link to your terrain project, the link appears to be broken.

    I would be most interested in having a look at the code details. Please advise.

    Nice Work!

    Mario

  18. Shamus says:

    Whoops. Sorry about the broken download. Should be fixed now.

  19. Rico says:

    Thank you so much for giving something the community can actually grasp regarding such a complex subject. Your article makes one feel just about anybody can make a terrain editor. I’m curious, what was the total time spent in its creation?

    Keep up the great work and I look forward to reading more of your insights and experiments.

  20. atirovav says:

    thanks a lot for your tutorial. its very usefull for me.

  21. Electronickid says:

    Umm, Shamus its simply awesome!

  22. Alan says:

    Hi Shamus, as a person who regularly employs programmers for web based stuff it is interesting to see a view from someone the other side of the keyboard.

    I suppose if I thought about it, I would realise that there were all kinds of tradeoffs, but this graduated view really shows what kinds of things you look at.

    I guess the logical progression is for you to create a full computer game based on your terrain engine.

    Seems reasonable…

  23. Swift says:

    Just wanted to say, as a programming student: this is awesome.

  24. Ian says:

    Wonderfull stuff dude. Anyone who is learning 3D game programming should go through your tutorial. You should publish a book. There’s a big lack of intermediate game programming tutorials.

  25. Kore says:

    Very nice!
    You wouldn’t by chance be doing more of these types of things in the future?
    It is a great learning tool!

  26. IneQuation says:

    Great stuff there, dude. I was looking for a terrain optimization algorithm for my engine and stumbled upon your blog accidentally, and found your project, with screenshots speaking more about its efficiency than mathematical formulas. I hope you don’t mind if I use your code as a reference implementation.

Thanks for joining the discussion. Be nice, don't post angry, and enjoy yourself. This is supposed to be fun. Your email address will not be published. Required fields are marked*

You can enclose spoilers in <strike> tags like so:
<strike>Darth Vader is Luke's father!</strike>

You can make things italics like this:
Can you imagine having Darth Vader as your <i>father</i>?

You can make things bold like this:
I'm <b>very</b> glad Darth Vader isn't my father.

You can make links like this:
I'm reading about <a href="http://en.wikipedia.org/wiki/Darth_Vader">Darth Vader</a> on Wikipedia!

You can quote someone like this:
Darth Vader said <blockquote>Luke, I am your father.</blockquote>

Leave a Reply

Your email address will not be published.