jeudi 23 avril 2015

How can I deterministically generate a seemingly random number given a seed and certain arguments?

I wrote a Perlin noise generator, but it depends on something pretty inconvenient: I have to pregenerate a grid of random vectors.

Ideally, I'd like have some function double f(int x, int y, int z, int seed) (or similar) that will always return an identical value given identical arguments, but whose results appear random enough for the noise generation over small ranges of x, y, and z. Then, in my noise generation algorithm, instead of indexing into the precomputed grid, it can generate a "random" vector on the fly. This way I could sample the noise function at coordinates bounded only by the limits of an integer, rather than bounded by the limits of memory.

Is such a thing possible? Obviously the randomness wouldn't be nearly as high-quality as precomputing the vectors, but I only really need something that appears random enough visually. Are there any existing methods of doing this?




Aucun commentaire:

Enregistrer un commentaire