POV-Ray : Newsgroups : povray.general : Simple trick for getting different random numbers in each render Server Time
10 Aug 2024 17:23:23 EDT (-0400)
  Simple trick for getting different random numbers in each render (Message 1 to 10 of 21)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Nieminen Juha
Subject: Simple trick for getting different random numbers in each render
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

From: Ken
Subject: Re: Simple trick for getting different random numbers in each render
Date: 30 Oct 1999 05:14:51
Message: <381AB6D3.676EC919@pacbell.net>
Nieminen Juha wrote:
> 
>   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.

Which part of the above allows for a new random number each time ?

-- 
Ken Tyler -  1100+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: omniVERSE
Subject: Re: Simple trick for getting different random numbers in each render
Date: 30 Oct 1999 05:22:24
Message: <381ab8d0@news.povray.org>
Using a random of a already random seed() I guess.
#write(ofile,int(rand(Seed)*1000000)), where Seed is always changed to use
previously generated random number.
Although I'm unsure how this is any different from simply doing so in the
first place without having to store it externaly.  Not that I'm smart enough
to know otherwise.

Bob

Ken <tyl### [at] pacbellnet> wrote in message
news:381AB6D3.676EC919@pacbell.net...
>
>
> Nieminen Juha wrote:
> >
> >   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.
>
> Which part of the above allows for a new random number each time ?
>
> --
> Ken Tyler -  1100+ Povray, Graphics, 3D Rendering, and Raytracing Links:
> http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: Bill DeWitt
Subject: Re: Simple trick for getting different random numbers in each render
Date: 30 Oct 1999 09:24:53
Message: <381af1a5@news.povray.org>
The part where you write a file to be read the next time. That file will
have a different seed number in it every time and your random result will be
different. I expect it would work just as well if it were...

> > #fopen ofile "seed.dat" write
> > #write(ofile,R+1)
> > #fclose ofile



Ken <tyl### [at] pacbellnet> wrote in message
news:381AB6D3.676EC919@pacbell.net...
>
>
> Nieminen Juha wrote:
> >
> >   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.
>
> Which part of the above allows for a new random number each time ?
>
> --
> Ken Tyler -  1100+ Povray, Graphics, 3D Rendering, and Raytracing Links:
> http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: Nieminen Juha
Subject: Re: Simple trick for getting different random numbers in each render
Date: 31 Oct 1999 03:05:11
Message: <381bf837@news.povray.org>
omniVERSE <inv### [at] aolcom> wrote:
: Although I'm unsure how this is any different from simply doing so in the
: first place without having to store it externaly.

  Show me an example code, thanks.

-- 
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

From: Ken
Subject: Re: Simple trick for getting different random numbers in each render
Date: 31 Oct 1999 03:07:29
Message: <381BF87F.217F1EFD@pacbell.net>
Nieminen Juha wrote:
> 
> omniVERSE <inv### [at] aolcom> wrote:
> : Although I'm unsure how this is any different from simply doing so in the
> : first place without having to store it externaly.
> 
>   Show me an example code, thanks.

Simple :)

#declare R = seed(1234); <- change this number anytime you want a different value

-- 
Ken Tyler -  1100+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: Nieminen Juha
Subject: Re: Simple trick for getting different random numbers in each render
Date: 31 Oct 1999 03:10:47
Message: <381bf987@news.povray.org>
Ken <tyl### [at] pacbellnet> wrote:
: #declare R = seed(1234); <- change this number anytime you want a different value

  I think that the idea was to get different values without changing the
code... :)

  Btw, who is the F1 champion?-)

-- 
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

From: David Wilkinson
Subject: Re: Simple trick for getting different random numbers in each render
Date: 31 Oct 1999 07:02:58
Message: <By8cOEAhoj3f5vCuCb4uriADt1b1@4ax.com>
On 31 Oct 1999 03:10:47 -0500, Nieminen Juha <war### [at] punarastascstutfi> wrote:

>
>  Btw, who is the F1 champion?-)

The same guy who collapsed in tears a couple of races ago when he spun off in the lead
:-)
He deserved to win, however, so well done the Finns (and the Brits/Germans for the
hardware).
David
------------
dav### [at] cwcomnet
http://www.hamiltonite.mcmail.com
------------


Post a reply to this message

From: omniVERSE
Subject: Re: Simple trick for getting different random numbers in each render
Date: 31 Oct 1999 07:42:42
Message: <381c3942@news.povray.org>
I was neglecting the fact about multiple renders, wouldn't be the same then.
Sorry about my confusion. Okay guys you can put the straightjacket back on
me now, through typing.
Think someone brought this up before... if by trying to supply a very small
or large number, then getting integer of some math done on it might return a
different number each time due to inaccuracies. That way it could be used as
the seed ( ) and no need to store one outside of POV.
I've tried it just now though and it doesn't seem possible.

Bob


Post a reply to this message

From: Charles
Subject: Re: Simple trick for getting different random numbers in each render
Date: 31 Oct 1999 09:58:04
Message: <381C5945.DAF30177@enter.net>
Novel approach.

>   Then add this at the end of your .pov file:
> 
> #fopen ofile "seed.dat" write
> #write(ofile,int(rand(Seed)*1000000))
> #fclose ofile
> 

Still think you should make stowing the next run's seed the first
thing you do once the stream is instantiated as opposed to putting
it at the end of the file. That way the whole process could be
coded as a #macro, which could be used to instantiate multiple
true random number streams on demand, making it more flexible
in the long run.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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