Hi!
I would like to have a random point Cd for each shader I had applied in Maya. When I import that in Houdini, I can see a prim s@shop_materialpath. I'm trying to generate a float value with the rand() fonction but it doesn't work with strings.
Any tips on having one Cd value per s@shop_materialpath name?
-Olivier
imported FBX: rand Cd per shader? SOLVED
1420 6 0- olivierth
- Member
- 1004 posts
- Joined: April 2017
- Offline
- mestela
- Member
- 1716 posts
- Joined: May 2006
- Online
- mestela
- Member
- 1716 posts
- Joined: May 2006
- Online
- olivierth
- Member
- 1004 posts
- Joined: April 2017
- Offline
AH!!
The function I was looking for is random_shash. I'm not exactly sure of the math behind that function but it converts a string (letters) to a long number. For example:
phone = 215330074
antenna_red = -1700732245
buttons = 2079827859
etc.
By passing those values in a rand() I was able to get different @Cd values.
-Olivier
The function I was looking for is random_shash. I'm not exactly sure of the math behind that function but it converts a string (letters) to a long number. For example:
phone = 215330074
antenna_red = -1700732245
buttons = 2079827859
etc.
By passing those values in a rand() I was able to get different @Cd values.
-Olivier
- jsmack
- Member
- 7658 posts
- Joined: Sept. 2011
- Online
olivierth
AH!!
The function I was looking for is random_shash. I'm not exactly sure of the math behind that function but it converts a string (letters) to a long number. For example:
phone = 215330074
antenna_red = -1700732245
buttons = 2079827859
etc.
By passing those values in a rand() I was able to get different @Cd values.
-Olivier
I wouldn't use rand() with a hash, the number is potentially far too big. Instead I use random(), which is meant to take integers.
- tamte
- Member
- 8444 posts
- Joined: July 2007
- Offline
jsmacknever used random(), but recently I had issue whith one scene where random() producd very biased random samples while when replaced with rand() it was pretty uniform, not that it may matter for this case, but it would be good to know the exact diffeerence between them and intended usage
I wouldn't use rand() with a hash, the number is potentially far too big. Instead I use random(), which is meant to take integers.
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- jsmack
- Member
- 7658 posts
- Joined: Sept. 2011
- Online
tamtejsmacknever used random(), but recently I had issue whith one scene where random() producd very biased random samples while when replaced with rand() it was pretty uniform, not that it may matter for this case, but it would be good to know the exact diffeerence between them and intended usage
I wouldn't use rand() with a hash, the number is potentially far too big. Instead I use random(), which is meant to take integers.
random() is for integers; it's used internally by attribrandomize. It's similar to cellnoise() in some other shading languages. rand() is for float seeds. I don't know about one being more or less random than another, but I know casting too large of an int to a float may cause rand() to behave less random as too many bits of precision are dropped. You can partially get around this by doing what attribute randomize does using a divide and modulus of 65365 to split the bits into to components of a vector.
-
- Quick Links