Jump to content

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!

Link to comment
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
Link to comment
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. 

Link to comment
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
Link to comment
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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...