Needed for dune generation.
Advantages over Noise.js implementation:
- No need to precompute or set a frequency.
- Guarantees a uniform range of [-1,1].
- Faster.
Differential D2454
Add 2d value noise for rmgen. nani on Dec 6 2019, 4:25 PM. Authored by
Details
Needed for dune generation.
Check output correctness.
Diff Detail
Event TimelineComment Actions I'm a bit confused about the seemingly random numbers in randomNoiseHashx and randomNoiseHashx. Otherwise looks good. Comment Actions The numbers are indeed "random" but they have a meaning. The idea behind is to make the sin wave have a frequency as high as possible and then multiplying that sin output by some large number then use the decimal part of that number (this is a quite known way to make noise in glsl shaders :) ) Some combinations of numbers give visible patterns and some others not because of aliasing, floating point precision, etc. I first did the testing in https://www.shadertoy.com/new to find the numbers that give these good enough result.
A way would be to check the output by logging the result for random points and seeing it always returns in the range [-1,1] and uniformly smooth random way. Take in consideration that the "randomness" hash in randomNoiseHashx doesn't expect input values very large or very small but in the range of 0.1 to lets say 5000.
Comment Actions https://smiley3.github.io/ The darker one is what I came up with. It's pretty much the same. Except that yours is always the exact same output. Good enough noise for shaders, but I really do not think we should limit ourselves in this environment and tbh identical output is a really big one (no matter how hard one ctrl-r, the top image just won't change :p ). If the current way is deemed acceptable, at least make it O(1), you can easily store all the values computed for a map of the size we support. Granted, my solution requires computing all the values in the *specific query* even if some would be discarded, but that is only if you need smoothing. That implementation is pretty cheap though. If you can make the case for this instead of fully random noise generation, I would be open to change.
|