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
1480 2 0- Justinngjw
- Member
- 8 posts
- Joined: April 2019
- Offline
- Enivob
- Member
- 2538 posts
- Joined: June 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 - Nov. 9, 2020 11:55:24
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- Justinngjw
- Member
- 8 posts
- Joined: April 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