|
![](/i/fill.gif) |
> One way to work around this issue is to use two random streams: the
> first is seeded by a constant and read in the while loop with one
> iteration per frame, and the second is seeded from the first
That would work if you used two *different* linear congruential generators.
However, since you are using the one and the same, I'm not sure it would
help anything.
It is, in fact, possible to completely replicate POV-Ray's rand() in SDL:
#declare SeedValue = 0;
#macro GetRand()
#declare SeedValue =
mod(Int32Mul(SeedValue, 1812433253) + 12345, 4294967296);
(SeedValue / 4294967295)
#end
#declare Int32Mul = function(v1, v2)
{
mod(v1, 65536) * mod(v2, 65536) +
mod(v1, 65536) * mod(int(v2/65536), 65536) * 65536 +
mod(int(v1/65536), 65536) * mod(v2, 65536) * 65536
};
//--------------------------------------------------------------------
#declare POV_seed = seed(0);
#declare Ind = 0;
#while(Ind < 20)
#declare SDL_rand = GetRand();
#declare POV_rand = rand(POV_seed);
#debug concat("SDL: ", str(SDL_rand, 0, 10),
", POV: ", str(POV_rand, 0, 10), "\n")
#declare Ind = Ind + 1;
#end
Post a reply to this message
|
![](/i/fill.gif) |