POV-Ray : Newsgroups : povray.general : Simple trick for getting different random numbers in each render : Simple trick for getting different random numbers in each render Server Time
10 Aug 2024 21:08:34 EDT (-0400)
  Simple trick for getting different random numbers in each render  
From: Nieminen Juha
Date: 30 Oct 1999 04:30:12
Message: <381aac94@news.povray.org>
People continously are asking for a way for getting different random numbers
from render to render.
  Well, the solution to this is so simple that I'm ashamed of not having
discovered it until now.

  Add this at the beginning of your .pov file:

#if(file_exists("seed.dat"))
  #fopen ifile "seed.dat" read
  #read(ifile,R)
  #fclose ifile
  #declare Seed=seed(R);
#else
  #declare Seed=seed(0);
#end

  Then use rand(Seed) in your pov code.

  Then add this at the end of your .pov file:

#fopen ofile "seed.dat" write
#write(ofile,int(rand(Seed)*1000000))
#fclose ofile


  It's that simple. Stupid me.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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