POV-Ray : Newsgroups : povray.tools.general : so stupid... Server Time
9 Oct 2026 08:45:42 EDT (-0400)
  so stupid... (Message 1 to 6 of 6)  
From: ingo
Subject: so stupid...
Date: 1 Sep 2026 09:12:16
Message: <6a96cf30@news.povray.org>
// 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

From: ingo
Subject: Re: so stupid...
Date: 1 Sep 2026 09:18:43
Message: <6a96d0b3$1@news.povray.org>
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

From: Leroy
Subject: Re: so stupid...
Date: 1 Sep 2026 15:50:00
Message: <web.6a972bf356e3329cc823645bf712fc00@news.povray.org>
ingo <ing### [at] nomailcom> 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

From: ingo
Subject: Re: so stupid...
Date: 2 Sep 2026 01:56:33
Message: <6a97ba91$1@news.povray.org>
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

From: William F Pokorny
Subject: Re: so stupid...
Date: 2 Sep 2026 13:27:04
Message: <6a985c68@news.povray.org>
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)

From: ingo
Subject: Re: so stupid...
Date: 3 Sep 2026 05:40:00
Message: <web.6a993ff356e3329cf3f28e9c8ffb8ce3@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> 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

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