Search Unity

Mathf.PerlinNoise() a way to random seed it?

Discussion in 'Scripting' started by Arowx, Jun 25, 2015.

  1. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    I find this function great and fast but there does not appear to be a way to set it so that it can be re-seeded with a new random noise set?

    Is this a missing feature or have I missed an indirect way to re-seed Mathf.PerlinNoise()?
     
  2. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    its not built in but you can
    Code (csharp):
    1. int newNoise = Random.Range(0,10000);
    2.  
    3. something = Mathf.PerlinNoise(x + newNoise, z + newNoise);
    there are a lot of "better" noise function for free on the internet.
    I use SimplexNoise usually.
     
    Leslieghf, Vazkuz and ManjiDM like this.
  3. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    There is no need to reseed Mathf.PerlinNoise() because it is virtually endless. Just pick a new random location to get values from.
     
  4. Croug

    Croug

    Joined:
    Mar 9, 2015
    Posts:
    6
    That would be seeding though, he is just looking for a way to make it so you don't produce the same numbers every time, and that would be how you do it.
     
    zeplar_exe and malkere like this.
  5. chrisx84

    chrisx84

    Joined:
    Nov 9, 2011
    Posts:
    85
    Code (CSharp):
    1. float Perlin(float x, float y)
    2. {
    3.         for(x; x< ChunkSize; x++)
    4.        {
    5.                 for(y; y < ChunkSize; y++)
    6.                 {
    7.                         return Mathf.PerlinNoise(x,y);
    8.                  }
    9.          }
    10. }
    Something like that. reseed in chunks.
    OORRRRR just use Input.GetKeyUp(KeyCode.E) to reseed with the E key.
    Code (CSharp):
    1. void Update()
    2. {
    3.  if (Input.GetKeyUp(KeyCode.E)) {
    4.   Mathf.PerlinNoise(x,y);
    5.  }
    6. }