Search - User list
Full Version: rand(float seed, float seed2)... seed2?
Root » Houdini Lounge » rand(float seed, float seed2)... seed2?
plagelpuss
Why does this function signature exist rand(float seed, float seed2)? What is the second seeds purpose?
tamte
for convenience
2 and more separate seeds are very common
As one can be promoted to ui and another can be internal, hence you can have multiple different random numbers controlled just by single seed value from UI

like:
float seed = chf("seed");
float r1 = rand(seed, 1);
float r2 = rand(seed, 2);
jsmack
It's great when you want random numbers based on point number or id and want to have a separate seed value.
plagelpuss
hmm I guess I am just trying to figure out why you would go through the trouble of creating the signature when there isnt much difference between (as far as code length/ “typing effort”)…

float seed = chf(“seed”);
float r1 = rand(seed, 1);
float r2 = rand(seed, 2);

and

float seed = chf(“seed”);
float r1 = rand(seed + 1);
float r2 = rand(seed + 2);

Does anyone know what the function does with the 2 parameters under the hood?
plagelpuss
I guess if you were looping over points using my example where you add values you could run into duplicate values fairly easily.
tamte
that's exactly the point
functions with 1D seed have this annoying workflow where you do seed+1 or seed*10+55 or whatever arbitrary expression just to try to get a unique set of random numbers
however there is either a large chance of repeating patterns for simple offset expressions or risk of running out of numbers with a crazy multiplier expressions
2D or nD seed simply allows for very clean workflow where you can change random sequence just by changing the seed in different dimension
similarly to a noise based on just a single float and noise based on vector2 or vector3, …
plagelpuss
Thanks for your help tamte,

Since rand(set(0,0)) == rand(0,0) I assume that the rand(a,b) function is just using set(a,b) under the hood.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB