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.
Q: Attribute wrangle > Attribute promote
15704 27 3- BabaJ
- Member
- 2036 posts
- Joined: Sept. 2015
- Offline
- YoungLegend
- 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..
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
- YoungLegend
- 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
- jsmack
- Member
- 7737 posts
- Joined: Sept. 2011
- Offline
- tamte
- Member
- 8525 posts
- Joined: July 2007
- Online
- jsmack
- Member
- 7737 posts
- Joined: Sept. 2011
- Offline
- YoungLegend
- 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 :
wrangle 2:
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
- tamte
- Member
- 8525 posts
- Joined: July 2007
- Online
Kishenthat's not surprising since a lot of times dedicated nodes for particular operations can be much faster than VEX if written correctly
Promote is actually a bit faster as well for some reason
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
FX Supervisor
Method Studios, NY
-
- Quick Links