POV-Ray : Newsgroups : povray.binaries.images : Toward a less-lame rand() function. : Re: Toward a less-lame rand() function. Server Time
4 Nov 2024 13:13:18 EST (-0500)
  Re: Toward a less-lame rand() function.  
From: Larry Hudson
Date: 16 May 2009 20:28:43
Message: <4a0f5a3b$1@news.povray.org>
gregjohn wrote:
> The neatly ordered, predictable pattern of red dots in the top half of the image
> are generated with povray's rand() function.  They demonstrate what you get if
> you cause a monotonic increase in the seed value.  Once I had a project
> "ruined" by this predictable pattern because I was exploring some parameter
> space via use of the #declare RSEED=seed(frame_number).
> 
The key to using a RNG is that it should be seeded once and ONLY once, 
before the RNG is used the first time.  That starts up a sequence of 
random numbers.  Then each time the RNG is called it gives you the next 
(pseudo) random number in the sequence.  If you try to seed it each 
time, you're not using a random sequence, it depends on however your 
seqence of seeds is defined.

Now, this can be a problem in POV-Ray animations because each frame is 
essentially created from scratch.  There's no built-in way to continue 
the RNG sequence between frames.  One possible approach is to save a 
final random number to a file and use that as the seed for the next 
frame.  But in a single, non-amimated image, don't use more than one 
initial seed.

Of course, since POV-Ray allows multiple random streams, this means that 
each one should be only seeded once -- and generally a different seed 
for each.

      -=- Larry -=-


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.