Set Absolute color

   1462   2   0
User Avatar
Member
6 posts
Joined: 4月 2019
Offline
Hello there,

May I know how to randomly set the colour to only red green and blue with no in-between?

thank you!

Attachments:
Screenshot 2020-11-09 163810.png (570.4 KB)

User Avatar
Member
2528 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.
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.
User Avatar
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

Attachments:
Screenshot 2020-11-09 170636.png (789.0 KB)

  • Quick Links