2
$\begingroup$

Python has a random module that allows you to get the following values

a = round(random.uniform(min, max), 4) - float number in the given range with rounding

b = random.random() - float number in range 0-1

Is it possible to implement these functions in OSL? I tried different ways with rand() or random value() but the output is error message.

Thank you!

$\endgroup$

1 Answer 1

2
$\begingroup$

Random value between 0 and 1.

float random_value = noise("uperlin", Seed)

Random value between min and max.

float random_uniform = min + random_value * (max - min)
$\endgroup$
1
  • $\begingroup$ I don't know OSL, but perlin noise probably doesn't yield uniform distribution and tends to be closer to 0.5? $\endgroup$ Commented Jul 11, 2023 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .