plagelpuss
July 15, 2019 22:09:12
Why does this function signature exist rand(float seed, float seed2)? What is the second seeds purpose?
tamte
July 16, 2019 00:06:20
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
July 16, 2019 17:49:54
It's great when you want random numbers based on point number or id and want to have a separate seed value.
plagelpuss
July 16, 2019 21:54:52
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
July 16, 2019 22:01:24
I guess if you were looping over points using my example where you add values you could run into duplicate values fairly easily.
tamte
July 17, 2019 01:26:45
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
July 17, 2019 21:55:59
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.