-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Perlin Noise Incorrect Adjustments #96
Comments
Sniping an old chat log, I found some of the ranges for the current function (this was picked out from thousands of data sets with size 0xC00 * 0xC00). (each row is a noted min/max selection)
So, (as per my calculator):
|
Wow, well that is interesting. Must be something wrong with our implementation. :( |
I did note what was currently (and obviously wrong): just that it's correcting (centering / scaling) data when it really doesn't need any correction. For the other part (strange cliffs), note that this is not comparative to original perlin noise (which may actually be worse), and the improved version (found here) has dramatic performance increase without much visual impact (and statistical comparison hasn't been made yet). @amaranth has insight to that on his blog post https://www.probablycoding.com/post/optimizing-perlin-noise/. |
So, this a two part issue (but the second part is just an awareness issue).
I ported the perlin2 code to Java, using 64-bit floating point (doubles), and did plots of the raw output. I noticed three interesting aspects of the data (third aspect is second part of the issue).
My observations are best explained by a few histograms:
http://imgur.com/a/Izngg (note, last image is random gaussian values as a reference for histogram behavior)
The line of issue: https://github.com/bjz/noise-rs/blob/d46df3fd9e37000a45fa76aad3fcdb85f4967318/src/perlin.rs#L43
The two constants there should be removed; the data's expected value (peak) at 0 without adding a constant, and the limits are at -1 and 1 without multiplying. After removing these two operations, the data begins to behave as expected. I tested with a data set of 613416960 (0xC00 width * 0xC00 height * 0x40 seeds), and my range was (-0.9999978883709002, 0.9999978883709002). I can provide some of the resulting histograms, but I'd just like to know that they're needed before I upload them.
Third thing I noticed, the data has mysterious small-scale biases (where there is a dramatically higher incidence of values on the other side of a threshold). They're noticeable as cliffs in the images. I don't have any suggestion for addressing it, or insight to how expected they are. I just thought that it should be noted by a maintainer as a possible issue.
I'm opening this as an issue instead of a PR because I suspect that perlin3 and perlin4 should receive similar analysis. If I have time, I can attempt to analyse those as well (or make my code available for another's use).
The text was updated successfully, but these errors were encountered: