Unity Community


Results 1 to 18 of 18

  1. Posts
    108

    3D Perlin Noise in progress (terrain generation, etc.)

    [26/03/11] : V. 0.01

    TerrainGen3.js

    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.

    Name:  Picture 4.png
Views: 8323
Size:  169.4 KB
    Some blocky terrain generated by the script (cubes are prefabs)

    Name:  Picture 2.png
Views: 7970
Size:  311.9 KB
    Overdraw view of perlin noise (not terrain, see notes in script)

    Settings:

    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.
    Last edited by •BTM; 03-26-2011 at 04:50 PM.


  2. Location
    Germany
    Posts
    453
    My first though when i opened this thread was: Minecraft
    Nice work!


  3. Location
    EU
    Posts
    360
    If you want your noise function be quicker google little about perlin noise.. There are newer implementations that were developed by Perlin himself that solve some problems with speed. Can't remember how it's named but utilizes different approach in computation and it's faster and more lightweight.


  4. Location
    UK
    Posts
    1,899

    Nice work!

    Nice Work...

    Shhh! Don't let notch know your making a unity version of M I N E C R A F T!


  5. Location
    Gold Coast, Australia
    Posts
    3,593
    Extremely Interested, been mucking around with similar myself recently.


  6. Location
    London, UK
    Posts
    220
    | www.quickfingers.net || Follow me on Twitter |

    Step-seq : A music creation toy based on ease of use and ear pleasing results!
    Stratosfear : A 7 Day Game Prototype Challenge based on themes "Rising" & "Companion"
    Surrender : Epic Sci-fi desert warfare
    SRL : My 7 day roguelike game on board an alien infested cargo space ship


  7. Location
    EU
    Posts
    360
    that's the one I was unable to remember... thanx quickfingers


  8. Location
    Bratislava, Slovakia
    Posts
    78
    Dude.. I was just checking out your fracture script and then I found this link in your signature. Your awesome . And this script is in JavaScript...I have to thank you .


  9. Posts
    439

    Not Perlin noise

    There are some common misconceptions about Perlin noise:

    Perlin noise, does not have octaves. It gives you just one single octave.

    A very common use of Perlin noise is to sample perlin noise at multiple frequencies (octaves), and add the results together at different scales. This is called fbm or Fractional Brownian motion. When you do this, instead giant smooth hills, you get giant hills with smaller features. This is a very common way to create realistic heightmaps.

    Perlin noise is a gradient based noise. What you are doing is called a value based noise, which has nothing to do with Perlin. The difference is: gradient noises calculate a gradient at each discrete point, values at the discrete points are always 0, and values between discrete points are obtained by projecting the gradients. On value noises, you calculate a value at each discrete point and interpolate the values for points between them.

    What you have implemented is a fbm of value based noises. Very similar to what is described here:
    http://freespace.virgin.net/hugo.eli...s/m_perlin.htm

    The author of that has the exact same confusion. He calls his fbm of value based noises "Perlin noise", so my guess is that is what you based your code on.

    If you are after speed, I recommend you implement simplex noise, as described here:
    http://webstaff.itn.liu.se/~stegu/si...mplexnoise.pdf

    That article also has a good explanation of what perlin noise really is.

    It is much harder to understand, but it just works faster and has higher quality. Also, allows you to calculate the derivative, which means that in your heightmap, you can calculate whether you are on a slope or not and how steep it is. You can then create an fbm (multiple octaves) based on simplex noise for interesting heightmaps, or even caves.

    If you wish to get some numbers: I calculate 7 million blocks calling 3d simplex noise 3 times and 2d simplex noise 4 times in 4.2 seconds . In order to create this:


    This video is outdated, as my terrain is much better nowadays, but it gives you an idea.


  10. Posts
    439
    Another good article that hopefully clarifies things is:

    http://developer.amd.com/assets/Tata...7-D3D_Day).pdf

    Page 16 shows you a simple value noise
    Page 17 shows you an interpolated value noise. This is essentially what you have in your function "InterpolatedNoise"
    Page 23 shows a gradient noise
    Page 24 and 25 shows a gradient noise with interpolation
    Page 36 shows simplex noise
    Page 42 shows fBM. This is equivalent to what you implemented.

    Here is an implementation of simplex noise with derivative, that you can easily translate to C#:
    http://mines.lumpylumpy.com/Electron...se/Simplex.php


  11. Location
    Mildenahll, United Kingdom
    Posts
    144
    I like your progress with this. Idk if you've read this, but here's another page devoted to procedural generation -- minecraft style

    http://www.gamedev.net/blog/33/entry...ype-world-gen/


  12. Location
    Bratislava, Slovakia
    Posts
    78
    Quote Originally Posted by Daxiongmao87 View Post
    I like your progress with this. Idk if you've read this, but here's another page devoted to procedural generation -- minecraft style

    http://www.gamedev.net/blog/33/entry...ype-world-gen/
    I like the article you posted.. I will look at it further a bit later but I like the cave generating method. Can't believe that I haven't came up with it sooner . I will try to rewrite your code so it doesn't instantiate cubes but that it makes the mesh procedurally instead if I have time...I so hate time .


  13. Location
    Mildenahll, United Kingdom
    Posts
    144
    Quote Originally Posted by dzebna View Post
    I like the article you posted.. I will look at it further a bit later but I like the cave generating method. Can't believe that I haven't came up with it sooner . I will try to rewrite your code so it doesn't instantiate cubes but that it makes the mesh procedurally instead if I have time...I so hate time .
    Glad it gave you some insight. It is not my post, I just happened to stumble upon it a while back and bookmarked it


  14. Posts
    439
    Quote Originally Posted by Daxiongmao87 View Post
    I like your progress with this. Idk if you've read this, but here's another page devoted to procedural generation -- minecraft style

    http://www.gamedev.net/blog/33/entry...ype-world-gen/
    Thank you for this. No, I had not read it, I wish I knew about that post 6 months ago


  15. Location
    Nebraska
    Posts
    378
    There is always this gem as well.
    http://forum.unity3d.com/threads/687...orted-to-Unity

    Fast, works well, and easy.


  16. Posts
    99
    i am wondering is it still alive cause none posted in long time and
    also what about Procedural part of process? is it possible to make it?
    No Image BBCode - NO SIGNATURE FOR YOU


  17. Posts
    644
    Marching cubes! DO IT! DO IT NAO!


  18. Location
    Kelowna, B.C, Canada
    Posts
    18
    Sorry for bringing this back up after three weeks, But I was wondering if I could get some tips or suggestions on having this generate in a hollow manner.

    As in only the sides and the top of the terrain are created and none of the cubes on the inside are instantiated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •