assigning minimum $CR to all points in a primitive group

   5451   4   1
User Avatar
Member
15 posts
Joined: March 2010
Offline
I have shattered geometry broken up into n primitive groups. With a point SOP, I color the points with $BBX in the diffr field. This gives me a black to red (0-1) ramp across all of the points.

Now, for each primitive, I want to determine the lowest value of $CR for that piece and set all points to be that same value.

So if “piece3” has $CR values of .2, .23, and .256, I want to set all points to have the same diffr of .2, and so on for each piece.

Someone smarter than me showed me how to do this once, and I'm trying to replicate it (to no avail).


chris

http://toonlets.com [toonlets.com]
User Avatar
Member
1909 posts
Joined: Nov. 2006
Offline
You can use an Attribute Promote SOP to get the minimun attribute value then use that to set all the values to that value. You could do this on a per piece basis using the ForEach SOP.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
15 posts
Joined: March 2010
Offline
Thank you. The AttributePromote example almost does what I'm after… I was able to accomplish what I wanted, but I wonder how you would do this…

Each shattered piece is made up of multiple primitives forming a primitive group. While I was initially able to get the minimum $CR value for each primitive and copy it to the other points of that primitive, I still had different colors per primitive in the overall primitive group.

I got around this with an add SOP. By deleting all of the primitives in a group, keeping the points, and then creating a single, new primitive (0-$N), I was then able to sample for the minimum value. I then copied this $CR back onto the original primitive group in a point SOP.

Is there a better/different way?

http://toonlets.com [toonlets.com]
User Avatar
Member
1909 posts
Joined: Nov. 2006
Offline
As long as each piece is a group you should be able operate over the entire piece to get the minimum value.

In the attached file I've got a bunch of spheres with different Y coordinates acting like fractured pieces. Each sphere is a group. The ForEach works on a per group basis. Inside the ForEach we get the minimum value and apply the color to the whole piece. Hopefully it's what you are going for.

Attachments:
red_by_bbox.hipnc (64.8 KB)

Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
15 posts
Joined: March 2010
Offline
Oh, I see. That's definitely a more elegant way of doing it.

Thanks.

http://toonlets.com [toonlets.com]
  • Quick Links