Search Unity

How would one create a simple fractal noise?

Discussion in 'Scripting' started by keenanwoodall, Jul 28, 2014.

  1. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Posts:
    598
    I'm not gonna ask anyone to write me a script cuz that would be unfair, but I am, however, curious on how to get started :)
     
  2. Dave-xP

    Dave-xP

    Joined:
    Nov 8, 2013
    Posts:
    106
    just make some noise, then add another noise with the double frequency on top of the first and you have a fractal noise with 2 octaves

    but if you need some noise functions here is my noise class http://cloud.invidec.net/public.php?service=files&t=9f91cd7b687ac5e973e2cc42dcbcfff9

    use it like..
    Code (csharp):
    1.  
    2. Texture2D texture = new Texture2D(200,200);
    3. for (int x = 0; x  < texture.width; x++) {
    4.     for (int y = 0; y < texture.height; y++) {
    5.         float noise = DaveNoise.ValueNoise2DCosine(x,y,120,0.45f,0.68f,10);
    6.         texture.SetPixel(x,y, new Color(noise,noise,noise));
    7.     }
    8. }
    9. texture.Apply();
    10.  
    Output will look like this
    DaveNoise_120_0.45_0.68_10.PNG
     
    Last edited: Jul 28, 2014
  3. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Posts:
    598
    thanks man!
     
  4. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Posts:
    598
    What about noise that is good for generating peaks and caves...Diamond-square algorithm?
     
  5. Dave-xP

    Dave-xP

    Joined:
    Nov 8, 2013
    Posts:
    106
    depends on what type of game you are trying to make
    but you could try 2D and 3D noise in combination to make caves and overhangs.