Perlin noise: I have the source code, now what?
I have been开发者_如何学Python looking all over the internet on how exactly to use the Perlin noise class (the C version), but I can't seem to find anything.
Here's what I'm doing:
double height = noise1(12);
NSLog(@"%f", height);
I set a double equal to noise1 with a random argument. Then I output height to the console with the NSLog
(objective-c). Now the strange thing is that the console outputs
Am I missing something?
Try, e.g.,
for(double x = 0; x < 10; x+=0.1)
{
double height = PerlinNoise1D(x,2,2,n);
//...
}
Here x
is the coordinate of the texture; it seems the functions the code is blending together are all 0 at integer values of x
so it makes sense that their blend is also always 0
. As best as I can tell n
is the number of functions to blend... not sure what the best value is, but 20ish seems to work well in some quick tests.
精彩评论