Add color point wrangle

   14207   3   0
User Avatar
Member
27 posts
Joined: June 2016
Offline
Hey,

using a point sop I can

Add color : rand($myvalue + 1) , rand($myvalue + 2) , rand($myvalue + 4)

and I can see $myvalue being used to drive the color on the points

$myvalue is a Primitive attribute, and obviously the point sop adding it to my point color.

How can I do this in a point Wrangle?
Problem being, I want to reference the $myvalue from a primitive and add it to the point. I don't want to attr promote in sops or anything like that.

Thanks!
Edited by ludwigvon - June 30, 2016 14:35:15
User Avatar
Member
2537 posts
Joined: June 2008
Offline
To randomize color just use VEX code inside the wrangle.
float r = random(@ptnum+1);
float g = random(@ptnum+2);
float b = random(@ptnum+3);
@Cd = set(r,g,b);
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
242 posts
Joined: Jan. 2008
Offline
Keep in mind that each point might have several connected primitives.
Here is a way to get average value from primitives.

@avgValue = 0;

//Fetch points conected primitives and store in array
int prims[] = pointprims(0,@ptnum);

foreach(int i; prims){
@avgValue += prim(0,"value",i);

}

@avgValue /= len(prims);
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
Most efficient way I know to drive random values into a vector is to use the vector rand(val1, val2) variant of the rand() function where there is a bound geometry attribute float myvalue:
@Cd = rand(f@myvalue+1, f@myvalue+2);
This will drive three random values in to Cd colour.
There's at least one school like the old school!
  • Quick Links