POV-Ray : Newsgroups : povray.general : problem: repeating rand patterns using seed in animation : Re: problem: repeating rand patterns using seed in animation Server Time
30 Jul 2024 18:12:59 EDT (-0400)
  Re: problem: repeating rand patterns using seed in animation  
From: Kenneth
Date: 26 Jan 2009 12:55:01
Message: <web.497df85db528db0df50167bc0@news.povray.org>
Nicolas George <nicolas$george@salle-s.org> wrote:

> There is something that was wasted, though: CPU time: in frame 100, CPU time
> is used to compute the random values #1 ... #99 in order to get to the #100
> although they have already been computed for frame 99.

I suppose that a more 'strictly logical' approach (in the sense of first
generating one large set of rand values to use, and not wasting any) would be
something like this, done only once during the first frame of animation:

#if(frame_number = 1)
#declare P = seed(1);
#local I = 0;
#while (I<frame_number)
#local my_rand = rand(P);
#write ***my_rand to a separate file***
#declare I = I + 1;
#end
#else
#end

Then, where I use my_rand in the scene...
#read ***a particular my_rand value from the pre-#written list***

I've left out the code details (and the 'details' may well quash the whole
scheme!), but the idea is to generate a complete list of random numbers (only
once), #write them all to a file, then #read back one rand value at a time for
use in the scene, as the animation progresses.

An interesting idea (probably the same as or similar to Warp's original
#write/#read scheme, now that I think of it.) I have no idea of its
'efficiency', though, compared to Chris B's original #while loop.

KW


Post a reply to this message

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