I'm using the LibNoise port from C++ to C# and running into problems generating Perlin noise (Unity demo here). For some odd reason integers never generate any noise. In the code below _firstValue on all axis has no decimal places and with perlin.GetValue(_firstValue); it returns zero. Adding a decimal place to either x/y/z of _firstValue will return a value with perlin.GetValue.

If anyone's ever used this library, any ideas on why something so simple like this demo seems to be causing so much of a head ache? Looking through the Perlin class, everything seems OK.

Vector3 _firstValue = new Vector3(-31.0f, 83.0f, -7.0f);

Vector3 _displacement = 0.0001f * Vector3.one;

Vector3 _secondValue = new Vector3(14.50f, 20.25f, 75.75f);

// Use this for initialization
void Start () 
    Debug.Log("Tutorial conversion for http://libnoise.sourceforge.net/tutorials/tutorial2.html");
    var perlin = new Perlin();
    Debug.Log(string.Format("First value: {0}", perlin.GetValue(_firstValue)));
    Debug.Log(string.Format("First value, displaced: {0}", perlin.GetValue(_firstValue + _displacement)));
    Debug.Log(string.Format("Second value: {0}", perlin.GetValue(_secondValue)));
  • 1
    \$\begingroup\$ When you say that "non-decimal place numbers never generate any noise," are you trying to say that integer value inputs always yields zero? Or that the function fails? Or something else altogether? From what I remember about Perlin noise, zero at integer locations was normal based on the implementation. \$\endgroup\$ – Steven Hansen Sep 3 '15 at 4:17
  • \$\begingroup\$ yes that's correct, integer value always returns a zero. \$\endgroup\$ – Euthyphro Sep 3 '15 at 4:27
  • \$\begingroup\$ try perlin .OctaveCount = <some number i.e 5 > \$\endgroup\$ – dnk drone.vs.drones Sep 3 '15 at 6:45
  • \$\begingroup\$ It is just odd, it always has to have a decimal place and cant be int number. \$\endgroup\$ – Euthyphro Sep 6 '15 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.