Q: Attribute wrangle > Attribute promote

   15704   27   3
User Avatar
Member
2036 posts
Joined: Sept. 2015
Offline
Hi Wren:

Maybe you could post a project or small example your working on in which you want to do that?

Then I'll insert the wrangle showing you how, and someone may also show a better way than how I do it.
Edited by BabaJ - April 26, 2018 16:39:11
User Avatar
Member
7 posts
Joined: Aug. 2015
Offline
Bringing this thread back to life.
I'm trying to compute min and max for multiple point attributes. I was able to initialize min and max for-each attributes to -1e7 and +1e7 using adddetailattrib fuction. But now i'm stuck at setdetailattrib. Pasting code..

string att = chs("../attributes");
string atts[] = split(att,' ');

foreach(string i; atts){
    adddetailattrib(0, i + "_min", 1e7);
    adddetailattrib(0, i + "_max", -1e7);
    
    setdetailattrib(0, i+"_min", "<read (i) as an attribute here>", "min");
    setdetailattrib(0, i+"_max", "<read (i) as an attribute here>", "max");
Edited by YoungLegend - May 20, 2021 14:07:14
User Avatar
Member
7 posts
Joined: Aug. 2015
Offline
Solved it. This only works for point attributes for now. Better solution anyone?

string att = chs("../attributes");
string atts[] = split(att,' ');

foreach(string i; atts){
    float val = point(0, i, @ptnum);
    adddetailattrib(0, i + "_min", 1e7);
    adddetailattrib(0, i + "_max", -1e7);
    
    setdetailattrib(0, i+"_min", val, "min");
    setdetailattrib(0, i+"_max", val, "max");
}
Edited by YoungLegend - May 20, 2021 14:08:21
User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
Kishen
Better solution anyone?

Attribute promote is the best solution.
User Avatar
Member
8525 posts
Joined: July 2007
Online
jsmack
Kishen
Better solution anyone?

Attribute promote is the best solution.
and the only thing better than Attribute Promote is 2 Attribute promotes
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
tamte
and the only thing better than Attribute Promote is 2 Attribute promotes

2 Attribpromote 2 Furious: the min-maxing
User Avatar
Member
7 posts
Joined: Aug. 2015
Offline
Promote is actually a bit faster as well for some reason. Especially when it comes to multiple attributes.
Pasting my final vex, incase anyone's curious. Packed into an hda.



wrangle 1 :
int runover = chi("../runover");
string att = chs("../attributes");
string atts[] = split(att,' ');

foreach(string i; atts){
    float val = runover==1?prim(0, i, @primnum):point(0, i, @ptnum);
    adddetailattrib(0, i + "_min", 1e10);
    adddetailattrib(0, i + "_max", -1e10);
    
    setdetailattrib(0, i+"_min", val, "min");
    setdetailattrib(0, i+"_max", val, "max");
}

wrangle 2:
int runover = chi("../runover");
string att = chs("../attributes");
string atts[] = split(att,' ');

foreach(string j; atts){
    float val = runover==1?prim(0, j, @primnum):point(0, j, @ptnum);
    float min = detail(0, j+"_min");
    float max = detail(0, j+"_max");
    
    if(ch("../toggle_fit")==1){
    float fit = fit(val,min,max,0,1);
    setpointattrib(0, j, @ptnum, fit, "set");
    }
    
    if(ch("../toggle_promote")==1){
    setpointattrib(0, j+"_min", @ptnum, min, "set");
    setpointattrib(0, j+"_max", @ptnum, max, "set");
    }
    
    if(ch("../toggle_avg")==1){
    float avg = avg(min, max);
    setpointattrib(0, j+"_avg", @ptnum, avg, "set");
    }
}
Edited by YoungLegend - May 25, 2021 13:17:10

Attachments:
Capture.PNG (14.9 KB)

User Avatar
Member
8525 posts
Joined: July 2007
Online
Kishen
Promote is actually a bit faster as well for some reason
that's not surprising since a lot of times dedicated nodes for particular operations can be much faster than VEX if written correctly
as VEX has it's limits
and while I don't know the algorithm used in Attrib Promote, the promoting to detail for example can be easily multithreaded for common cases like min, max, sum, ..., while in VEX you are sort of forced to queue all the updates into a single threaded queue
even worse if you also iterate over attributes sequentially
Edited by tamte - May 25, 2021 23:35:53
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links