POV-Ray : Newsgroups : povray.binaries.images : Toward a less-lame rand() function. : Re: Toward a less-lame rand() function. Server Time
31 Jul 2024 18:25:48 EDT (-0400)
  Re: Toward a less-lame rand() function.  
From: Reactor
Date: 17 May 2009 03:20:00
Message: <web.4a0fba322a89ae6db5db26f70@news.povray.org>
Larry Hudson <org### [at] yahoocom> wrote:
> 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 -=-

This sounds familiar ;)

The op may want to read this thread here:
http://news.povray.org/povray.general/thread/%3Cweb.497a1e5215dcf5ebf50167bc0%40news.povray.org%3E/?ttop=307384&toff=50
&mtop=300618

Of particular interest is this posting:
http://news.povray.org/povray.general/message/%3C497a49fd%241%40news.povray.org%3E/#%3C497a49fd%241%40news.povray.org%3
E
To make a long story short, one can use the frame number to iterate through the
stream, so that a "random" number is used for each frame.

That said, I would like to see a new, stronger rand function in a future
version.


-Reactor


Post a reply to this message

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