POV-Ray : Newsgroups : povray.binaries.scene-files : self seeding random Server Time
2 Sep 2024 12:15:34 EDT (-0400)
  self seeding random (Message 1 to 3 of 3)  
From: Pete
Subject: self seeding random
Date: 25 Mar 2001 11:46:53
Message: <232.484T1923T7045532PeterC@nym.alias.net>
Here is an include file containing two macros that can
be used to get scenes that have a different random number seed
each time they are run.  A file called "randseed.pov" is created
to store the seed between renders.

Pete


Post a reply to this message


Attachments:
Download 'random.inc.txt' (2 KB)

From: Dennis Milller
Subject: Re: self seeding random
Date: 28 Mar 2001 20:26:57
Message: <3ac28f61$1@news.povray.org>
Sorry, not quite sure how to apply this. Could you throw in a demo scene
file using the random value for, say, the r value in an rgb vector?
thanks much,
D.

"Pete" <Pet### [at] nymaliasnet> wrote in message
news:232### [at] nymaliasnet...
>         Here is an include file containing two macros that can
> be used to get scenes that have a different random number seed
> each time they are run.  A file called "randseed.pov" is created
> to store the seed between renders.
>
> Pete
>


----------------------------------------------------------------------------
----


> /*
>    a system for self-reseeding randomness in povray.  This enables a
povray
>    file have a different random number seed each time it is run.
>
>    To use, simply include this file, then call "get_seed()" once.  Then
use
>    rseed as your seed troughout your render.  The last atatement in your
.pov
>    file should be a call to "update_seed()".
>
>    The random seed will be stored in "randseed.pov"
> */
>
>
> #macro get_seed()
>   #if (file_exists("randseed.pov") = 1)
>     #include "randseed.pov"
>     // what if the file was bad or incomplete?
>     #ifndef (rseed) // was this defined?
>       // no.  It was not.  Fake it and hope better for next time around
>       #render "bad randseed.pov file ... making a new one\n")
>       #declare rseed = seed(83963179);
>     #end
>   #else
>     // The file was not found.  Fake it and hope better for next time
around
>     #render "no randseed.pov file found ... making a new one\n")
>     #declare rseed = seed(74747285);
>   #end
>   #ifndef (rseed)
>     #render "\nWTF!  rseed STILL not defined!  That's impossible!!\n"
>     #render "\g YOU HAVE A PROBLEM!!!!!\n"
>   #end
> #end
>
>
> // update the random seed now that we are done with it.
> #macro update_seed()
>   #ifdef (rseed)
>     #local new_seed = 99999999 * rand(rseed);
>     #local new_seed = int(new_seed);
>     #fopen F1 "randseed.pov" write
>     #write (F1, "#declare rseed = seed(", str(new_seed, 0, 0), ");\n")
>     #write (F1, "#render \"Seed used is: seed(", str(new_seed, 0, 0), ")
\"\n")
>     #write (F1, "#render \"\"\n")
>     #fclose F1
>   #end
> #end
>
>
> /* actual end of this_file */
>


Post a reply to this message

From: Pete
Subject: Re: self seeding random
Date: 4 Apr 2001 22:23:51
Message: <250.494T1171T12794852PeterC@nym.alias.net>
>Sorry, not quite sure how to apply this. Could you throw in a demo scene
>file using the random value for, say, the r value in an rgb vector?
>thanks much,
>D.

Sure.  Render the attached file three or four times
and you'll see what I mean ...   :)


Post a reply to this message


Attachments:
Download 'sure.pov.txt' (62 KB)

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