3
\$\begingroup\$

I was looking for some inspration for my Voxel based game I am writting and came across this: http://www.youtube.com/watch?v=rL8zDgTlXso. I would like to know how to go about (or preferably source examples) of how I would do that, in real time, and infinitley. In addition to that I was wondering how I would do this with a voxel based terrain?

A procedural planet generator in 3D which constructs voxel data, my voxels are of the same size of thoose in minecraft.

Any ideas?

Edit:

I ported the simplex noise function i_grok suggested written in C++/Python to C#, I sure hope it works :)

http://pastebin.com/TZSQwnye

Edit 2:

float noise(float x, float y, float z, float persistance, float amplitude, float frequency, float octaves)  {
    float total = 0;

    for (int i = 0; i < octaves; i++)  {
        frequency = frequency ^ i;            // or frequency *= 2; ?
        amplitude = amplitude ^ i;

        total = total + SimplexNoise.raw_noise_3d(x * frequency, y * frequency, z * frequency) * amplitude;
    }

    return total;
}
\$\endgroup\$
4
  • 5
    \$\begingroup\$ The search phrase that rubs the magic djinni lamp is "procedural content generation." \$\endgroup\$ Commented Feb 18, 2012 at 10:13
  • \$\begingroup\$ Also keep in mind that depending on your approach (such as your coordinate system scale and rendering pipeline), you will run into a myriad of issues with finite precision errors in rendering and positioning objects. Generating noise for terrain is trivial compared to these issues. \$\endgroup\$ Commented Feb 18, 2012 at 17:12
  • 1
    \$\begingroup\$ -1. I can't figure out whether the question is far too broad, or far too trivial. Or maybe both. Regardless, there is no concrete question here which can be authoritatively answered. \$\endgroup\$ Commented Feb 19, 2012 at 5:10
  • \$\begingroup\$ Here are the things to search for, as the video specifically mentions what it is using for the LOD (How it zooms from space to land) and also the algorithm for the terrain generation: "The application uses quadtrees for LOD, and generates terrain using the ridged multifractal algorithm on both CPU and GPU (in a GLSL shader)." \$\endgroup\$
    – James
    Commented Feb 19, 2012 at 19:40

3 Answers 3

6
\$\begingroup\$

There are already a lot of resources. You can start with this post on gamedev: How are voxel terrain engines made?

These answers may be closer to your question: Voxel heightmap terrain editor

Most of the noise functions discussed here are fine for real-time - some can generate a million values a second. I'm not aware of a C# implementation, but what you're looking for is Simplex Noise (sometimes called Improved Perlin Noise). Simplex Noise can scale to any number of dimensions, but most people seem to implement 2D, 3D and 4D. I have implemented Simplex Noise in C and Python if you wish to port from there. There is also a Java implementation of Simplex Noise.

\$\endgroup\$
11
  • \$\begingroup\$ I have already written the voxel engine, so, in my question I asked how I would I go about makeing a procedural infinite world out of voxels in 3D. \$\endgroup\$
    – Darestium
    Commented Feb 19, 2012 at 4:34
  • \$\begingroup\$ The post I linked to in my answer briefly touches on the solution. You need to select some reasonable noise functions to generate the terrain. From what I've seen so far, everyone ends up implementing their engine differently but relies on the same sets of procedural functions. \$\endgroup\$
    – i_grok
    Commented Feb 19, 2012 at 5:10
  • \$\begingroup\$ Thanks! Got any recomendations for perlin noise functions? I am using one, but it's 2D, and in addition to the 2D noise I would like to do 3D, but I cannot seem to find a tutorail on 3D perlin noise anywhere, let alone how to use it. \$\endgroup\$
    – Darestium
    Commented Feb 19, 2012 at 6:53
  • \$\begingroup\$ @Darestium mrl.nyu.edu/~perlin/noise The man's website itself goes over the differences between 2D and 3D noise (just passing in 2 or 3 values IIRC). I think you can also find a few 'globe' type rendering demos on his site if it helps. \$\endgroup\$
    – James
    Commented Feb 19, 2012 at 19:44
  • \$\begingroup\$ @i_grok , thanks! I managed to convert the java code into c#! But I am wondering how do I actually go about using it? With 2D it is simple just height = noise[x, z] but what does the value returned represent in 3D perlin noise? \$\endgroup\$
    – Darestium
    Commented Feb 29, 2012 at 5:46
2
\$\begingroup\$

I was interested in this a while back. There is a (now old, but still relevant) book called Texturing and modelling: a procedural approach. One of the authors is Ken Musgrave aka Dr. Mojo who created mojoworld. There is a chapter in that book about procedural planet generation that you may find helpful.

\$\endgroup\$
3
  • \$\begingroup\$ Great book - I own it! I suspect it's a bit more theoretical than what Darestium is hoping for, though. \$\endgroup\$
    – i_grok
    Commented Feb 19, 2012 at 5:04
  • \$\begingroup\$ Thanks, I'll give it a try :) I really hope I can understand it :) \$\endgroup\$
    – Darestium
    Commented Feb 19, 2012 at 6:47
  • \$\begingroup\$ @bobobobo Would you recomend me to purchase it? \$\endgroup\$
    – Darestium
    Commented Mar 8, 2012 at 9:26
0
\$\begingroup\$

If you are using Voxel/Boxels to represent your planet, you've got a problem ahead, planets are big balls of stuff, and cubes don't map onto the surface of balls very well.

You could use non-cubic blocks, but distortion will increase as you travel to the poles (and a stack of blocks will have to be wedge shaped)

You could volume fill a planet with blocks but there will be problems when you start approaching the horizon (as the down vector will change)

if you're really clever you will be able to generate the blocks on the fly to match volumetric data, but it won't be a 1:1 mapping like minecraft.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .