[26/03/11] : V. 0.01
Small update; Faster, removed the yields in the script as well, although it stops unity while the script is thinking. For a terrain using default settings (calculating 131,072 points), it should be created in under 2 minutes; still very slow, between 1000 & 1200 points per second.
I found some extra time these past couple of days, and decided I'd play with Unity for a bit. I figured that I'd come up with a procedural terrain system allowing overhangs, tunnels, etc.
I started last night, and got some of it working this morning. I began by looking up perlin noise, and making my own implementation of 3d perlin noise (or something similar) using the now-accessible multi-dimensional builtin arrays.
I have it working, but it is incredibly slow, as it always seems to be with codes in the first little while after writing them. Also, I'm making the terrain out of cubes, which means that it resembles minecraft a lot (hopefully I can change this by using something similar to marching cubes, and then smoothing).
It does work very similarly to minecraft, in that they both use 3d perlin noise. I also decided to generate terrain in blocks, because it seems to be the only feasible method to generate terrain in real time and save it (I'm still not there yet).
Well, I'm posting it in this early stage because I figure it could be a useful start for others who might know a lot more about this type of thing than me. I'm also not sure how much time I'll have in the next little while to improve it.
More notes can be found in the script itself.
Some blocky terrain generated by the script (cubes are prefabs)
Overdraw view of perlin noise (not terrain, see notes in script)
Terrain Blocks : The amount of blocks in the x & y directions the script creates. (4 would be a 4x4 grid of terrain blocks)
Cube : A cube prefab goes here.
Detail Size : The distance between integral areas, or at least that's how I like to describe it. Basically, the size of the noise. (since it's not limited to a terrain size)
Persistence : How noisy the terrain will be. (persistence in Perlin noise)
Octaves :Amount of iterations it goes through, in which size and persistence change each iteration. (octaves in Perlin noise)
Terrain Size : The length and width of a terrain block; the total size of the terrain is (Terrain Size)^2*(Terrain Blocks)^2.
Terrain Height : The maximum height of the terrain (average height is half of this)
Seeded : The random terrain seed. The same seed will always generate the same terrain.