Aren't x and y the seed value?
Not in the sense of the OP, because the function isn't a pseudo random number generator at all. It is just a function f : I[sup]2[/sup] -> [-1, 1][sub]R[/sub]
For every pair (x, y) put in you'll get a deterministic result independent on the history of requests so far.
In CG one often wants PRN generators that generate reproducible number sequences, just to ensure that e.g. an appearance doesn't alter randomly (
) from frame to frame. So the question is: The function is thought for ... what purpose? Why feeding in 2 parameters where a single one would have been equally good (e.g. noise( x + y * 57 ) if one wants to reduce the dimensionality).
To answer the OP in a general way: Make 2 function, the 1st to set the seed and the 2nd to request the next PRN. Let the seed function set a private variable, and let the request function base on that private variable
and alter it. E.g.
private Int32 n;
public void setSeed(Int32 x, Int32 y) {
n = x + y * 57;
}
public double getNoise() {
// altering n
n = ((Int32)n << (Int32)13) ^ (Int32)n;
n = (n * (n * n * 15731 + 789221) + 1376312589);
n = n & 0x7fffffff;
// transforming into result range
double nDouble = (double)n / 1073741824.0d;
return (1.0d - nDouble);
}
(w/o saying that this is a good generator, and ignoring that x and y may have a special purpose). The point is that the n is stored, so that a sequence of requests can generate different results for each invocation.
EDIT: Either I'm so slow in writing or LorenzoGatti's post was deferred by the internet