POV-Ray : Newsgroups : povray.newusers : rand not producing random! : Re: rand not producing random! Server Time
8 Jul 2024 02:43:22 EDT (-0400)
  Re: rand not producing random!  
From: Mike Williams
Date: 7 Jan 2010 15:13:32
Message: <KxZQilEYAkRLFwc$@econym.demon.co.uk>
Wasn't it geogeo who wrote:
>
>So is there any way at all to produce a randomised number within POV?

Some versions of MegaPOV had a tick_count variable which returns the 
value of the computer's internal clock variable.

In official versions of POV, one thing you can do is pass an external 
value into the scene with a command line "Declare" and use that value as 
the seed. If you launch POV from a programming language that has access 
to the computer's internal clock variable, you could pass that value 
into the scene that way.

Another approach would be to store the seed in an external file. Read 
the value with fopen and fread, use it as the seed for the current scene 
then change the value (e.g. by adding 1) and write it back. That way, 
the next time you run that scene you get a different seed value. That 
also has the advantage that if you decide that the version of your scene 
that you rendered three iterations ago had a particularly pretty random 
pattern that you'd like to go back to, you can examine the file and work 
out what the seed would have been.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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