3

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;
}
Darestium
  • 1,154
  • 2
  • 14
  • 34
  • 5
    The search phrase that rubs the magic djinni lamp is "procedural content generation." – Patrick Hughes Feb 18 '12 at 10:13
  • 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. – KlashnikovKid Feb 18 '12 at 17:12
  • 1
    -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. – Trevor Powell Feb 19 '12 at 05:10
  • 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)." – James Feb 19 '12 at 19:40

3 Answers3

6

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.

i_grok
  • 186
  • 4
  • 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. – Darestium Feb 19 '12 at 04:34
  • 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. – i_grok Feb 19 '12 at 05:10
  • 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. – Darestium Feb 19 '12 at 06:53
  • @Darestium http://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. – James Feb 19 '12 at 19:44
  • @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? – Darestium Feb 29 '12 at 05:46
  • @Darestium 3D and 4D noise are to be used the same way as 2D. For example, you might have multiple points on the surface of a sphere. You could call 3D noise to apply colors to those points or to apply some type of perturbation (such as translating along the vertex normal). height = noise[x, y, z] – i_grok Mar 01 '12 at 21:47
  • Also, how does one take amplitude, persistance and frequency into account when using these functions as they seem t only have noise(float x, float y, float z)? – Darestium Mar 10 '12 at 08:07
  • @Darestium You need to read up on multi-octave noise. If you need to figure out how to write multi-octave noise, then look back at my C or Python multi-octave noise implementations. – i_grok Mar 10 '12 at 21:23
  • So from what I have read I would create a function as in Edit 2? Or is that totally incorrect, or... Do I have to use the interpoliate/smooth functions as well? – Darestium Mar 11 '12 at 03:30
  • @i_grok This is based off your C++ implementation (the added code in edit 2) – Darestium Mar 11 '12 at 07:45
  • @Darestium At this point, it's up to you. It doesn't look like the function you've written will return values in [-1, 1] but you'll still get usable values. I'm planning to add more sophistication to my library (such as smoothing functions and others) but haven't needed them yet. You'll have to see what works and what doesn't in your application. – i_grok Mar 11 '12 at 16:32
2

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.

bobobobo
  • 17,074
  • 10
  • 63
  • 96
0

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.

salmonmoose
  • 854
  • 5
  • 12