 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
// Normally I use one stream for everything, or I create one stream per
subject
// in first case when I add something somewhere that needs the stream it
also changes the rest of the scene.
// In the case of a stream per subject I have to change everything by
hand if I want a different seed.
// Then, after decades of struggle ...
// yes you already knew how to do it but kept it secret, don't tell me.
// Makes me feel even worse :(
// It finally clicked:
// Change Seed and it all changes.
// Add something in between and give it its own seed and the rest stays
the same.
// To change the seed for one subject, pick another number from the array
#macro Sower(N, Seed)
#declare R0 = seed(Seed);
#declare Seeds = array[N];
#for (i, 0, N-1)
#declare Seeds[i] = seed(int(rand(R0)*10000));
#end
#end
#declare N = 10;
#declare Seed = 7;
Sower(N, Seed)
//naming step is not needed per se.
#declare RndStones = Seeds[0];
#declare RndFlowers = Seeds[1];
#for (i,0,9)
#debug concat(str(rand(RndStones),1,1), " ",
str(rand(RndFlowers),1,1),"\n")
#end
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
As I said in the title.... better version with multiple sowers
---%<------%<------%<---
#macro Sower(N, Seed)
#local R0 = seed(Seed);
#local Seeds = array[N];
#for (i, 0, N-1)
#declare Seeds[i] = seed(int(rand(R0)*10000));
#end
Seeds
#end
#declare N = 10;
#declare Seed = 7;
#declare One = Sower(N, Seed);
#declare Two = Sower(N, 8);
//naming step is not needed per se.
#declare RndStones = One[0];
#declare RndFlowers = One[1];
#for (i,0,9)
#debug concat(str(rand(RndStones),1,1), " ",
str(rand(RndFlowers),1,1),"\n")
#end
---%<------%<------%<---
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
ingo <ing### [at] nomail com> wrote:
> As I said in the title.... better version with multiple sowers
>
> ---%<------%<------%<---
> #macro Sower(N, Seed)
> #local R0 = seed(Seed);
> #local Seeds = array[N];
> #for (i, 0, N-1)
> #declare Seeds[i] = seed(int(rand(R0)*10000));
> #end
> Seeds
> #end
>
>
> #declare N = 10;
> #declare Seed = 7;
>
> #declare One = Sower(N, Seed);
> #declare Two = Sower(N, 8);
>
> //naming step is not needed per se.
> #declare RndStones = One[0];
> #declare RndFlowers = One[1];
>
>
> #for (i,0,9)
> #debug concat(str(rand(RndStones),1,1), " ",
> str(rand(RndFlowers),1,1),"\n")
> #end
> ---%<------%<------%<---
You don't have to have an array of seed values!
Every time you make a new seed POV's seed function adds that seed to an built_in
array and returns the element number of that array.
So when you first start with #declare S=seed(35423); S=0;
The next time you declare a seed like #declare R=seed(35423); then R=1; and so
on...
So all you need to know is how many seeds you made.
You don't even have to use a variable in the random statement you can use the
number!!
as in #declare A=rand(0);
I wouldn't call what you did as stupid. I just call it a habit. Like I've used
sky_sphere forever for a simple sky and the other day going though the documents
I found out that you could use layered pigments?! HABIT
Have Fun!
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 2026-09-01 21:49, Leroy wrote:
> You don't have to have an array of seed values!
> Every time you make a new seed POV's seed function adds that seed to an built_in
> array and returns the element number of that array.
> So when you first start with #declare S=seed(35423); S=0;
> The next time you declare a seed like #declare R=seed(35423); then R=1; and so
> on...
>
> So all you need to know is how many seeds you made.
>
> You don't even have to use a variable in the random statement you can use the
> number!!
> as in #declare A=rand(0);
>
> I wouldn't call what you did as stupid. I just call it a habit. Like I've used
> sky_sphere forever for a simple sky and the other day going though the documents
> I found out that you could use layered pigments?! HABIT
>
> Have Fun!
>
---%<------%<------%<---
#macro Sower(N, Seed)
#local R0 = seed(Seed);
#for (i, 0, N-1)
#local s = seed(int(rand(R0)*10000));
#end
#end
#declare N = 10;
#declare Seed = 7;
Sower(N, Seed)
//Sower(N, 8);
#for (i,0,9)
#debug concat(str(rand(0),1,1), " ", str(rand(1),1,1),"\n")
#end
---%<------%<------%<---
That works fine. But now, how to create a second stream of streams? (do
I need that? In audio/DSP I use it to compare room reverbs, a new stream
of streams is a new room. Does it make sense for use in POV-Ray?)
ingo
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 9/2/26 01:56, ingo wrote:
> That works fine. But now, how to create a second stream of streams? (do
> I need that? In audio/DSP I use it to compare room reverbs, a new stream
> of streams is a new room. Does it make sense for use in POV-Ray?)
I don't know... :-)
Underneath the streams of evenly distributed random values is a hashing
function - or sometimes a pre-calculated, cached set of 'random'/hashed
values.
I don't remember (or perhaps never investigated) the seed()/rand() code
implementation. I suspect it's a cached set of values - or perhaps a
somewhat constrained hashing function - see below.
---
We have in our documentation interesting, example seed values for two
streams:
#declare R1 = seed(0);
#declare R2 = seed(12345);
If you print the first four rand(R1 and R2 stream) values you get:
// 0.000 0.467
// 0.467 0.249
// 0.249 0.966
// 0.966 0.637
The R2 stream is one 'index' ahead of the R1 stream - which suggests
value caching (An array of random values) or hashing code constraints
for our seed()/rand() implementation.
---
Some general rules / suggestions :
1) Using zero as a seed, is with most numeric hashing functions, a bad
idea because it initially - or always, depending - returns zero.
2) In POV-Ray use random-ish seed() values for each stream of multiple
streams if you want to make value 'echoes', as happens above, less
likely.
3) If you want the same stream of values for multiple independent
streams you can use the same seed() value for those streams.
4) For sets for streams something like your approach workable I think.
Or maybe something like:
#declare strmSetNum = 2;
#declare R1 = seed(98765 * strmSetNum);
#declare R2 = seed(12345 * StrmSetNum);
---
In the attached yuqk scene file I've included an example using the
curious seed values from our documentation as mentioned above.
Plus, code showing how to implement seed()/rand() with yuqk's new
inbuilt f_hash() function (a wrapper of C++'s hashing library function
for doubles).
Using the f_hash() function directly (I think) makes it more apparent
how the hashing function is getting used to create multiple streams of
'random' values.
Bill P.
Post a reply to this message
Attachments:
Download 'ingohmm.pov.txt' (2 KB)
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
William F Pokorny <ano### [at] anonymous org> wrote:
> On 9/2/26 01:56, ingo wrote:
> > That works fine. But now, how to create a second stream of streams? (do
> > I need that? In audio/DSP I use it to compare room reverbs, a new stream
> > of streams is a new room. Does it make sense for use in POV-Ray?)
>
> I don't know... :-)
Thanks for not knowing ;) and the information despite that,
ingo
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |