Friday, January 13, 2012

Infinite Terrain Test

The last few days, I've been busy modifying a lot of my base code to cater for chunks (Despite this having become the de facto term, I hate using it and will be thinking up a new one soon). You can now walk around to your hearts content and terrain will just pop up (shaded and all) around you. Deallocation of memory (both CPU and GPU) is handled and theoretically you should be able to carry on running forever.

As you can see from the screenshots and executables (link below), I ran into some trouble with shading. Because raytracing is done on surfaces and surfaces are shaded in chunks, shading will look off at the edges. To counter this, I've generated padding terrain data for chunks but modifying my nest of code to take that into account is not yet completely ready.

The actual terrain also looks off in some places (edges again) which is probably just some simple division error I made somewhere. I'll hopefully pick that up soon. Also, the camera can't rotate infinitely to the left and it can rotate/move into terrain, giving the impression that you're in a very dark place.

Lastly, if you rotate the camera while having fraps open, you should see the fps jumping around a lot. This is due to the terrain not being sorted exactly right (front to back). I've implemented sorting of chunks which helped even it out a bit but, inside chunks, it is still possible for the closest voxels to be drawn last.

Perlin Noise

Simplex Noise

Next, I'll probably need to sort out the ordering of voxels so I can implement water (rendering translucent faces requires faces to be rendered in the correct order).

I'm visiting family for the weekend, after which work should pick up quite a bit but you can still expect regular (albeit less spirited) updates.


  1. Neat project your working on.

    I had a question about your blog though. How did you set up the lightbox that opens up when you click on the image files? I've been searching for one as nice as the one you are using.

    Thanks for any help.

    1. The feature is enabled by default for blogspot pages. If you're on blogspot and don't have it, maybe your theme doesn't support it?

  2. Looking good! I'm looking forward to your next post!

    Alternatives for "chunk" that you could use:


  3. Well Perlin seems quite nice to the eyes and Simplex feels like is doing holes on the ground. If Minecraft chunk loading worked that fast..

    (Heights, sort of "bug") You can't stand on top a tile that has two heights (two tiles with same X and Z, but two Y coordinates).
    Your system always forces the user to the lower one.

    Keep going, you are doing it great!

    1. Dah.. it's not "two Y coordinates", it's "two non equal coords". Sorry about that.

      I couldn't make a screenshot to draw arrows on.

  4. Great progress, looking forward to seeing more :)

  5. Hey! First I want to say then your engine is really awesome! Amazing that you can make this.

    Second, as I'm sort of a programmer myself, how did you learn this? What are the steps to go to Voxel engine and simplex/perlin noise?

    (I program in C#/XNA but the theory doesn't differ)

    1. Thanks for the compliment. I'll be posting more informative, tutorial-esque articles soon.

    2. Thank you a lot for that then! I'll be looking forward to it!

  6. I'm having a very hard time coding this. I would appreciate if you could write a tutorial.

  7. Hi, I was just wondering what kind of rendering you do which gives sort of a shadowy effect. Is it Ambient Occlusion, or something simpler? I have looked into Ambient Occlusion but so far it is too complicated for me.

  8. Hey man. This is AO yes. I might write a tutorial on it soon.

  9. That would be great -- there is a lot of material on AO online, but it is mostly for traditional polygonal meshes, not voxels. I would think a voxel AO routine would be simpler?