POV-Ray : Newsgroups : povray.tools.general : so stupid... : Re: so stupid... Server Time
9 Oct 2026 07:37:49 EDT (-0400)
  Re: so stupid...  
From: William F Pokorny
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)

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