Question

I just started to do some tests with libnoise, from the documentation about getvalue(), this method should return a value from -1 to 1, but the next code (not so far of this tutorial) return some values over 1:

// g++ test.cc -lnoise#include<iostream>
#include<noise/noise.h>

int main(){
  noise::module::Perlin Ken; // Ken Perlin dat's the guy who developed the noise
                             // I do some noise some time too... more heavy \m/
  int i; // dat's the guys who dev... just kidding...
  int j;
  double dragon; 

  for(j=0;j<100;j++) for(i=0;i<100;i++){
    dragon = Ken.GetValue(double(i)/100.,double(j)/100.,0.5);
    if(dragon>1)std::cout<<"("<<double(i)/100.<<";"<<double(j)/100.<<")= "<<dragon<<std::endl;
  }
return 0;
}

then I try copy+paste the tutorial and change one thing, the point where I want to get the value. Obviously, I use a point where my code return a value over 1, let say : (0.8,0.19,0.5) who gave 1.00101. So,

#include <iostream>
#include <noise/noise.h>

using namespace noise;

int main (int argc, char** argv)
{
  module::Perlin myModule;
  double value = myModule.GetValue (0.8, 0.19, 0.50);
  std::cout << value << std::endl;
  return 0;
}

and still returns 1.00101 who's still over 1... so now, I see nobody complains about that on google & co. so don't know if I mess with something or not, but since I used the tutorial and since the point isn't particular, I think it's not my fault...

(I can still get the max and min and normalize)

I now also opened a bug ticket for this.

Était-ce utile?

La solution

There is a bug in the GradientNoise3D function (noisegen.cpp). The final dot product is multiplied by 2.12, supposedly to bring values to be within the [-1,1] range. However, the correct value should be 0.57735... (1/sqrt(3))

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top