Jump to content
defc0n1

Point cooler from scatter using attribute wrangle

Recommended Posts

Hey guys.

I'm pretty new to the houdini world, and I've been experimenting a lot of things. Is there a way to get the RGB values of scattered points using attrib wrangle? Im not too familiar with the VEX syntax, so Im having a hard time figuring it out. I have random colours signed to a scatter node and some geometry copied on to the points using a copy node. I want to limit  scatter the geometry based on the colour of the scattered point. Thanks!

Share this post


Link to post
Share on other sites

Sure, with a wrangle running over points, you have access to each points color with the @Cd attribute. In this code, any objects that have a red color greater than 0.9 will be scaled to 0, thus not appear in the scene. All others will get a scale of 1 and appear in the scene.

if (v@Cd.r > 0.9) {
    v@scale = 0;
} else {
    v@scale = 1;
}

 

Edited by Atom

Share this post


Link to post
Share on other sites
5 minutes ago, Atom said:

Sure, with a wrangle running over points, you have access to each points color with the @Cd attribute. In this code, any objects that have a red color greater than 0.9 will be scaled to 0, thus not appear in the scene. All others will get a scale of 1 and appear in the scene.


if (v@Cd.r > 0.9) {
    v@scale = 0;
} else {
    v@scale = 1;
}

 

Just a heads up that this can be problematic, even though they're not visible they are still there. So potentially you could end up with tons of infinitely small geometry; they aren't visible but still take up memory and whatnot. 

Share this post


Link to post
Share on other sites

Skybar is right, just keeping it simple. This is an old mograph trick and is safe to use up to hundreds of objects/points on most hardware. If you get up into higher points counts you may want to remove the points that you don't want copies on.

Like so.

if (v@Cd.r > 0.9) {
    removepoint(0,@ptnum);
}

The @ptnum attribute is the actual point number that the wrangle is currently evaluating. If you are running over primitives there is a similar attribute called @primnum.

Edited by Atom

Share this post


Link to post
Share on other sites

Thank a ton, guys! You're awesome. Works like a charm. The sheer power of Houdini has me in awe, actually. 

Can I export a variable or set a parameter based on the input Cd that I can access from other nodes? For example a switch?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×