Hello there,
May I know how to randomly set the colour to only red green and blue with no in-between?
thank you!
Set Absolute color
1443 2 0- Justinngjw
- Member
- 6 posts
- Joined: 4月 2019
- Offline
- Enivob
- Member
- 2519 posts
- Joined: 6月 2008
- Offline
Sure, you can use a fit function inside an attributeWrangle, and force the result into an integer.
Make sure to run over Primitives, not points, assuming you have packed primitives.
Make sure to run over Primitives, not points, assuming you have packed primitives.
int color_index = int(fit01(rand(@primnum),0,3)); if (color_index == 0){v@Cd = set(1,0,0);} if (color_index == 1){v@Cd = set(0,1,0);} if (color_index == 2){v@Cd = set(0,0,1);}
Edited by Enivob - 2020年11月9日 11:55:24
Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- Justinngjw
- Member
- 6 posts
- Joined: 4月 2019
- Offline
Enivob
Sure, you can use a fit function inside an attributeWrangle, and force the result into an integer.
Make sure to run over Primitives, not points, assuming you have packed primitives.int color_index = int(fit01(rand(@primnum),0,3)); if (color_index == 0){v@Cd = set(1,0,0);} if (color_index == 1){v@Cd = set(0,1,0);} if (color_index == 2){v@Cd = set(0,0,1);}
Thank you very much, thats really helpful! Just to let you know I wanted each geo to have its own colour, not each primitive, so I changed your code to @class instead of @primnum after I added a connectivity node before the wrangle. Again thanks man
-
- Quick Links