Noise via python

Hi,
I’m writing a driver script that needs to use some noise function, preferably mathutils.noise.turbulence. But all I get is 0.0 no matter the input value or which mathutils.noise I try to use. It’s there anyone that have managed to get this to work?
I’ve tried both in the script file and in the console but nothing gives a value other than 0.0. I don’t get any errors so I believe the syntax is acceptable, I assume the error is due to my inexperience with python.
Could someone show me a script or console input that should work? Or at least tell me that they have got it working so I don’t spend even more hours chasing ghosts! Thanks in advance! :blush:
Cheers!

Well, you could use mathutils.noise.turbulence_vector() as a workaround for now, to at least not get stuck. :man_shrugging:

noise, _, _ = mathutils.noise.turbulence_vector((i, 0, 0), 1, 1)

edit:

>>> mathutils.noise.turbulence((0.1, 0., 0.0), 1, 1)
0.13475632667541504

mathutils.noise.turbulence((i, j, k), 1, 1)
Any of i, j, k needs to be between 0 and 1. Returns 0.0, if all are <=0 or >=1.

1 Like

Thanks for the input @DanielEngler, much appreciated!
I actually got the nose function fully working by help from a colleague who is way more python savvy than me. (My preferred language is C, python is not strict enough for my taste or brain to fully wrap around it.) I will get back to this thread and post the script and some shots on the rig when it’s ready.

But as you write, there is something strange with inputting 1.0 or 0.0 in the position vector. It seems from my experiments that it’s the same for all position vectors consisting of solely integers, the output noise value then becomes 0.0, at least for mathutils.noise.turbulence. Do you know why it’s like that? Could very well be some rtfm that I should’ve done :stuck_out_tongue:

1 Like

I’ve no clue why the noise function behaves like that. I didn’t rtfm. :grin:

The only strict thing in python is the indentation.
Since 3.5 we have type hinting. That’s something I should use to prevent me from some headaches. :grin:

1 Like