instance random colors

   6906   3   2
User Avatar
Member
5 posts
Joined: Nov. 2016
Offline
hello everyone,
complete newbie here, sorry for wasting your time.

I am trying to randomly copy several sets of geometry “assembly” on some grid points
i am using instance SOP (as i am planning to use this with heavier geometry later on)
My scene was inspired by this exemple: “Instance with instance sop”
http://www.tokeru.com/cgwiki/?title=Houdini [www.tokeru.com]


Two questions:

_I am happy with the random distribution of geometry but I am also looking for a way to attribute random colors to each piece of my geometry sets.
All i have been able to do so far is add a “color” node set to random under my wrangler but obviously
this will only attribute the same color to the whole set.
If you look at my image, “A” is where i am, i would love to get to “B” (which is for now made with photoshop)



_What would be the best way to have some control over the randomness of colors ?
Lets imagine i want it to randomly pick among a set of 3 or 4…. predefined colors. ?

Thank you for your advice.

Attachments:
michelm_instance.hiplc (107.3 KB)
Capture.JPG (639.7 KB)

User Avatar
Member
833 posts
Joined: Jan. 2018
Offline
I don't know how to do it, but I suspect the answer is probably with instancing a For/Each loop. Sorry if I can't help in more detail as I'm currently trying to wrap my head around the For/Each loop nodes myself, but it might give you a tip toward looking into that as a solution.

http://www.sidefx.com/docs/houdini/nodes/chop/foreach.html [www.sidefx.com]
>>Kays
For my Houdini tutorials and more visit:
https://www.youtube.com/c/RightBrainedTutorials [www.youtube.com]
User Avatar
Member
2528 posts
Joined: June 2008
Offline
All the Color node does in Houdini is set the value of the @Cd attribute.
In your setup delete the color node.
Under the grid points drop down an attribute wrangle running over points.
Then you can generate a random number based upon the point number.
int rnd_index = int(fit01(rand(@ptnum), 0,3));
v@Cd = set(1,0,0);  // Default to red.
if (rnd_index==0) {v@Cd = set(0.5,0.25,0.6);}
if (rnd_index==1) {v@Cd = set(1,0.25,0.6);}
if (rnd_index==2) {v@Cd = set(0.5,1,0.6);}
if (rnd_index==3) {v@Cd = set(0.5,0.25,1);}
When the copies are generated they will inherit the color from the points.
Edited by Enivob - March 19, 2018 15:55:52
Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
5 posts
Joined: Nov. 2016
Offline
Thanks guys for the quick reply !

Midphase, thanks for the tip, i will try to play with the “Foreach” node,
i found few exemple, …. some clearer than others.

Enivob, thank you for those few lines of Vex, simple way to have control on the color
distributed. I am not sure to understand though why when writing

int rnd_index = int(fit01(rand(@ptnum),0,3));

if i m using 4 rnd_index like in my exemple it will never pick the last one
(rnd_index==3)

if (rnd_index==0) {v@Cd = set(1,0,0);}
if (rnd_index==1) {v@Cd = set(0,1,0);}
if (rnd_index==2) {v@Cd = set(0,0,1);}
if (rnd_index==3) {v@Cd = set(1,1,0);}

no big deal, it works fine if i change “int(fit01(rand(@ptnum),0,3))”
with “…,0,4))”…i just don't understand what it means,
…0,3 i m guessing means from 0 to 3 so that s 4 “sets” 0123
so why would i need to write 0,4 for it to hit (rnd_index==3)?



thank you anyway, this is already progress,
i still have to figure out how to affect each “sub object” contained
in my geometry sets.
Right now each geometry set is duplicated on @ptnum
so my wrangler affect “a” which is fine for the geometry distribution
but “a” contains aa,ab and ac
how can i affect aa,ab,ac independently for the @Cd random distribution ?

Sorry to bother you with this,
i live alone in the middle of a forest
it is taking me forever to figure out this software
on my own.
Thank you for any further advice

m

Attachments:
michelm_instance_02.hiplc (94.7 KB)

  • Quick Links