Code snippet: Houdini groom hair chance maps
- Ellie Ansell
- Nov 15, 2020
- 1 min read
Used for adding colour attributes to hairs for the hair shader.
Paint maps on the skin, e.g. 'mask_cd_white'
Use Guide Skin Attrib. Lookup to transfer the paint maps to the prim hairs.
Use the code snippet (or similar - depending on if you're using points/prims) to give a chance of assigning a hair with an attribute.
string attr = chs("cd_strays");
string group=chs("coloured");
float attr_val = 0.0;
if(!inprimgroup(0, group, @primnum))
{
attr_val = prim(0, attr, @primnum);
if(f@elem<chramp("chance", attr_val))
{
v@Cd = set(1,1,0);
setprimgroup(0, group, @primnum, 1, "set");
setprimattrib(0, attr, @primnum, 1, "set");
}
else
{
setprimattrib(0, attr, @primnum, 0, "set");
}
}
else
{
setprimattrib(0, attr, @primnum, 0, "set");
}

Comments