 |
 |
|
 |
|
 |
|  |
|  |
|
 |
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] pacbell net> 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] pacbell net> 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] aol com> 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] aol com> 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] pacbell net> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 31 Oct 1999 03:10:47 -0500, Nieminen Juha <war### [at] punarastas cs tut fi> 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] cwcom net
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 31 Oct 1999 03:10:47 -0500, Nieminen Juha <war### [at] punarastas cs tut fi>
wrote:
>Btw, who is the F1 champion?-)
Hey, OT! I haven't seen the Suzuka race, yet, Warp! It's due to be
televised in my area, tape-delayed, in about 20 minutes. Someone may answer
your question so I can't read this thread any further <s>.
--
Alan - ako### [at] povray org - a k o n g <at> p o v r a y <dot> o r g
http://www.povray.org - Home of the Persistence of Vision Ray Tracer
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Nieminen Juha
Subject: Re: Simple trick for getting different random numbers in each render
Date: 1 Nov 1999 03:57:38
Message: <381d5602@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Alan Kong <ako### [at] povrayno-spam org> wrote:
: Hey, OT! I haven't seen the Suzuka race, yet, Warp! It's due to be
: televised in my area, tape-delayed, in about 20 minutes.
Sorry. I didn't realize that this kind of thing would happen :/
--
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: Nieminen Juha
Subject: Re: Simple trick for getting different random numbers in each render
Date: 1 Nov 1999 04:02:29
Message: <381d5725@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Actually you are right. It could be done better this way:
#macro Randomize()
#if(file_exists("seed.dat"))
#fopen ifile "seed.dat" read
#read(ifile,R)
#fclose ifile
#else
#local R=0;
#end
#declare Seed=seed(R);
#fopen ofile "seed.dat" write
#write(ofile,R+1)
#fclose ofile
#end
To use it, call it at the beginning of the file:
Randomize()
and the use rand(Seed) where needed.
--
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 1 Nov 1999 03:57:38 -0500, Nieminen Juha <war### [at] punarastas cs tut fi>
wrote:
>Sorry. I didn't realize that this kind of thing would happen :/
Just semi-kidding <s>. I didn't read the thread any further until after I
saw the race.
--
Alan - ako### [at] povray org - a k o n g <at> p o v r a y <dot> o r g
http://www.povray.org - Home of the Persistence of Vision Ray Tracer
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Chris Huff
Subject: Re: Simple trick for getting different random numbers in each render
Date: 2 Nov 1999 05:23:46
Message: <381EBC4D.DE21BBF3@yahoo.com>
|
|
 |
|  |
|  |
|
 |
Just one question: Why do you want different numbers each session? It
would just make debugging harder...
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Nieminen Juha
Subject: Re: Simple trick for getting different random numbers in each render
Date: 2 Nov 1999 05:32:46
Message: <381ebdce@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Chris Huff <chr### [at] yahoo com> wrote:
: Just one question: Why do you want different numbers each session? It
: would just make debugging harder...
I didn't say that _I_ want different numbers in each render. However, there
are many people who want. Ask them :)
There are some situations where "real" random numbers are useful (instead
of having the same series on number each time).
--
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Nieminen Juha wrote:
>
> Chris Huff <chr### [at] yahoo com> wrote:
> : Just one question: Why do you want different numbers each session? It
> : would just make debugging harder...
>
> I didn't say that _I_ want different numbers in each render. However, there
> are many people who want. Ask them :)
> There are some situations where "real" random numbers are useful (instead
> of having the same series on number each time).
One example would be a web page that offers a render on line example of
how povray works. With a truly random number there would be no reason to
ask the visitor to supply a seed amount since it would be automated and
each time it was activated the visitor would see a completely different
example.
--
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: Chris Huff
Subject: Re: Simple trick for getting different random numbers in each render
Date: 2 Nov 1999 05:50:28
Message: <381EC28E.D413C619@yahoo.com>
|
|
 |
|  |
|  |
|
 |
The only situation I can think of is where you want a bunch of different
versions of an object. In that case I simply seed the stream with a
large number multiplied by clock.
#declare globalRandStream = seed(50000*clock);
Then I just make an animation of it, and pick out the good versions.
Not saying this is better or anything, just the way I do it.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Margus Ramst
Subject: Re: Simple trick for getting different random numbers in each render
Date: 2 Nov 1999 15:08:52
Message: <381F4457.F044D0CA@peak.edu.ee>
|
|
 |
|  |
|  |
|
 |
I see a potential problem here. Consecutive seeds can give numbers that are
markedly non-random. For example, make a loop to generate a string of spheres,
whose y position is a random number whose seed changes linealrly:
#declare C=0;
#while(C<100)
#declare S=seed(C);
#declare R=rand(S);
sphere{<C,R,0>,1}
#declare C=C+1;
#end
Chris Huff wrote:
>
> The only situation I can think of is where you want a bunch of different
> versions of an object. In that case I simply seed the stream with a
> large number multiplied by clock.
>
> #declare globalRandStream = seed(50000*clock);
>
> Then I just make an animation of it, and pick out the good versions.
>
> Not saying this is better or anything, just the way I do it.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Chris Huff
Subject: Re: Simple trick for getting different random numbers in each render
Date: 2 Nov 1999 15:59:51
Message: <381F5163.E1DB8D0B@yahoo.com>
|
|
 |
|  |
|  |
|
 |
A good reason to use a really big number for the multiplier, isn't it?
But yes, you are right, that could possibly become a problem.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Charles
Subject: Re: Simple trick for getting different random numbers in each render
Date: 3 Nov 1999 20:53:45
Message: <3820A8F1.97AFFADD@enter.net>
|
|
 |
|  |
|  |
|
 |
Chris Huff wrote:
>
> Just one question: Why do you want different numbers each session? It
> would just make debugging harder...
A couple of projects have occured to me that could use such a beast,
although they have (so far) been of the "neat, but not worth diverting
attention to now" variety. A few ...er.. random ideas:
An abstract art program that keeps a repetoire of objects, textures,
lighting and view elements in separate INC files, and generates
random pieces each time it's run.
An animation script running a variation on the Life Genesis game
which randomly arranges the starting positions of the life pods (in
this case blob components) in 3D space so each run is genuinely
unique.
A POV-Ray file that generates a random figure from a Tarot
deck (or Norse rune cast, or I Ching, or magic 8-ball response,
or... well, you get the idea: plenty of variations) and renders it
along with a text object, or scroll or something expounding the
meaning. For obvious reasons if it kept rendering the same
cast/draw/hexagram each time, it would be self defeating.
You *could* just manually reseed every time, but its just the
principle of having it self contained. Again, it's all stuff to
do when you're bored and don't have a main project or if you have
a more powerful computer than you know what to do with <g>, but
hey, it's a simple enough trick and it might come in handy
sometimes.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |