Search Unity

Documentation correction

Discussion in 'Documentation' started by revolute, Oct 10, 2014.

  1. revolute

    revolute

    Joined:
    Jul 28, 2014
    Posts:
    50
    http://docs.unity3d.com/ScriptReference/Mathf.PerlinNoise.html

    It is said to return a value between 0 and 1 while I found that they return values larger than 1.
    The largest value I have seen is 1.0123.

    perlinlog.PNG

    This is my code. zFrequency and xFrequency are both 40.

    Code (CSharp):
    1. void GenerateAlphaMap()
    2.     {
    3.         float[, ,] maps = terrain.terrainData.GetAlphamaps(0, 0, terrain.terrainData.alphamapWidth, terrain.terrainData.alphamapHeight);
    4.         for (int y = 0; y < terrain.terrainData.alphamapHeight; y++)
    5.         {
    6.             for (int x = 0; x < terrain.terrainData.alphamapWidth; x++)
    7.             {
    8.                 float perlinValue = Mathf.PerlinNoise(x / zFrequency, y / xFrequency);
    9.  
    10.                 if (perlinValue > 1)
    11.                 {
    12.                     Debug.Log(perlinValue + " at " + x + ", " + y);
    13.                 }
    14.             }
    15.         }
    16.     }
     
  2. Rasmus Selsmark

    Rasmus Selsmark

    Joined:
    Mar 13, 2013
    Posts:
    120
    Hi @revolute, thanks for your feedback. However sounds more like a bug in the API, rather than in the documentation, if it can return values above 1. For now I assume you just ignore values higher that 1 (using Max() or similar methods)?

    I will suggest that you report this as a bug using Help -> Report a Bug in Unity including a good repro case. (don't know if the one above can be sent to us)

    Best regards, Rasmus