POV-Ray : Newsgroups : povray.general : Simple trick for getting different random numbers in each render Server Time
11 Aug 2024 01:17:34 EDT (-0400)
  Simple trick for getting different random numbers in each render (Message 12 to 21 of 21)  
<<< Previous 10 Messages Goto Initial 10 Messages
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-spamorg> 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

From: Alan Kong
Subject: Re: Simple trick for getting different random numbers in each render
Date: 2 Nov 1999 04:22:49
Message: <=qweOPaxYroqa3Se1XLBJRugWi3q@4ax.com>
On 1 Nov 1999 03:57:38 -0500, Nieminen Juha <war### [at] punarastascstutfi>
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] povrayorg - 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] yahoocom> 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

From: Ken
Subject: Re: Simple trick for getting different random numbers in each render
Date: 2 Nov 1999 05:49:46
Message: <381EC0D8.57DB3E7E@pacbell.net>
Nieminen Juha wrote:
> 
> Chris Huff <chr### [at] yahoocom> 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

<<< Previous 10 Messages Goto Initial 10 Messages

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