|
![](/i/fill.gif) |
Jérôme M. Berger wrote:
> Warp wrote:
>> Kenneth <kdw### [at] earthlink net> wrote:
>>> "Kenneth" <kdw### [at] earthlink net> wrote:
>>>> "Chris B" <nom### [at] nomail com> wrote:
>>>>> #declare P = seed(1);
>>>>> #local I = 0;
>>>>> #while (I<frame_number)
>>>>> #local ThrowAway = rand(P);
>>>>> #declare I = I + 1; // added by Kenneth ;-)
>>>>> #end
>>>> That's quite interesting, and it makes great sense--it pulls a nice random value
>>>> for each frame. I'll try it!
>>> Yes indeed, it works as advertised. Wonderful! Who cares if it wastes some rand
>>> values; that's what computers are FOR! :-P
>> Actually it doesn't waste any values. In fact, the end result is very
>> similar to the #write/#read solution, but without having to use the temporary
>> file.
>>
>> Or it is, if you only want one random value per frame. If you want several
>> random values per frame, then you have to "read away" all the random values
>> from the RNG stream that have been used in previous frames.
>>
>> If the number of random numbers generated per frame varies from frame
>> to frame, then it can become difficult to achieve the desired effect
>> without #write/#read.
>>
> 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:
> #declare P = seed(1);
> #local I = 0;
> #while (I<frame_number)
> #local ThrowAway = rand(P);
> #declare I = I + 1;
> #end
> #declare P = seed (P)
Sorry, the last line should be:
#declare P = seed (rand (P))
Jerome
--
mailto:jeb### [at] free fr
http://jeberger.free.fr
Jabber: jeb### [at] jabber fr
Post a reply to this message
|
![](/i/fill.gif) |