Fastest method to copy all point attribs given a target ID?

   1286   2   1
User Avatar
Member
900 posts
Joined: 2月 2016
Offline
My scenario:
All the point attributes in the geometry have their values shuffled.
For example, Point 0 now holds the original attrib values of Point 313, while Point 0 original values are now copied to Point 45, etc.
A i@targetID attribute tells who is the original attributes owner, so that you can use it to copy and restore the original values.
In this case: @targetID for Point 0 is 45, and @targetID for Point 313 is 0;
So to restore the original color attribute I would simply do v@Cd = point(0, "Cd", i@targetID);

But it's a dynamic scenario. I need to copy ALL the point attributes, whose names and types are not known in advance, and can change.
I need to find a solution faster than using Attribute Copy SOP, because that node is too slow.
Going the Vex route, I see that setpointattribute() function is useless here, because it is even slower.

I thought I could use backticks to declare and set dynamically an attribute, but they don't work this way?
// this won't work

string attribName = "Cd";
string attribType = "v";
`attribType`@`attribName` = point(0, attribName, i@targetID);

`attribType`@`attribName` = point(0, attribName, i@targetID);


If anybody wants to give it a try, I prepared a test scenario, with my failed attempt
Edited by Andr - 2022年11月23日 07:53:34

Attachments:
fastCopy_pointAttribs_with_id.hiplc (114.9 KB)

User Avatar
Member
4512 posts
Joined: 2月 2012
Offline
For large number of points Attribute Interpolate SOP can crush Attrib Copy in performance. The only issue is that it requires array attributes even if it's only for a single element and weight. RFE submitted: #105259, #124296

So you can create array attributes like this and then use Attribute Interpolate SOP:

i@targetpt = array ( i@targetID );
f@targetweight = array ( 1 );

For 25M points I get about 30% faster performance:

Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
900 posts
Joined: 2月 2016
Offline
animatrix_
For large number of points Attribute Interpolate SOP can crush Attrib Copy in performance. The only issue is that it requires array attributes even if it's only for a single element and weight. RFE submitted: #105259, #124296

So you can create array attributes like this and then use Attribute Interpolate SOP:

i@targetpt = array ( i@targetID );
f@targetweight = array ( 1 );

For 25M points I get about 30% faster performance:

img]https://i.imgur.com/vVUxcUa.png [i.imgur.com]


Thanks for the suggestion, I tried with "Attribute Interpolate Sop" but I'm finding it's very slow compared with "Attribute Copy Sop", even with 20million points. Could you please check the attached file and see if I'm doing something wrong?

In the new file you'll find also a new experimental method: it's a dynamic generation of vex code in Python to transfer the attributes using the simple point(0, "myattrib", i@targetID).
This method seems to be faster than Attribute Copy Sop, with high number of points.
But maybe I just wasted my time, because I'm missing this Attribute Interpolate thing.


Note: I simplified the test scenario, because the earlier version was a bit ambiguous.
I restate the idea: every point is assigned with a unique random targetID, to be used to copy the attributes from another point in the same geo. This produce just a change in the point number, but all the attributes remain in position. So it's like using a "Sort SOP" in random mode.
Edited by Andr - 2022年11月24日 10:23:59

Attachments:
fastCopy_pointAttribs_3_methods.hiplc (124.0 KB)
dynamicVexCode.JPG (190.1 KB)

  • Quick Links