Atom Posted August 1, 2015 Share Posted August 1, 2015 (edited) Hi All, I am trying to port an hScript expression in a point node to a point wrangle but the wrangle is not performing as expected. In the Point node I am modifying the position with an expression to create a helix. $TX+sin($TY*ch("../line1/freq")) * ch("../line1/amp") $TZ+cos($TY*ch("../line1/freq")) * ch("../line1/amp") This works and you can see the helix on the left. Then I merge in a Point Wrange and put the following code in place. float x, z, freq, amp; freq = ch("../line1/freq"); amp = ch("../line1/amp"); x = sin(freq)*amp; z = cos(freq)*amp; vector result = set(x,0,z); @P += result; This produces a straight line, however? I guess I need a way to gain access to the $TY component of @P inside of VEX? I tried this but get an error. float x, z, freq, amp; freq = ch("../line1/freq"); amp = ch("../line1/amp"); x = sin(@P.y*freq)*amp; z = cos(@P.y*freq)*amp; vector result = set(x,0,z); @P += result; How do I access other elements of a vector in VEX? Hmm...I guess a pythonic attempt seems to work when reading from an attribute. float x, z, freq, amp; freq = ch("../line1/freq"); amp = ch("../line1/amp"); x = @P[0] + sin(radians(@P[1]*freq))*amp; z = @P[2] + cos(radians(@P[1]*freq))*amp; vector result = set(x,@P[1],z); @P = result; ap_VEX_based_helix.hipnc Edited August 1, 2015 by Atom Quote Link to comment Share on other sites More sharing options...
Atom Posted August 1, 2015 Author Share Posted August 1, 2015 (edited) Now that I have the VEX code version working, it matches the Point node exactly. When I middle click on the Point node I see that it takes 0.16ms to cook. The Wrangle takes 0.13ms to cook. I was under the impression that VEX as much faster? These kinds of small gains seem marginal. . . . Ok, I upped the point count from 36 to 10,000 and the speed gains are more apparent. With 10,000 points in my helix the Point node takes 30.22ms to calculate and the Wrangle node reports 0.12ms. When I increase the point count to 60,000 the Point node reports 187.22ms and the Wrangle node reports 0.16ms. That is a more significant speed gain. Edited August 1, 2015 by Atom Quote Link to comment Share on other sites More sharing options...
edward Posted August 2, 2015 Share Posted August 2, 2015 There's currently a largish overhead in VEX nodes to do the initial setup. Plus, they currently multi-thread on blocks of 1024 elements. So it's hard to see an improvement under 1024 items. Say you have 8 cores, then to really see the improvements, you need at least 8*1024=8192 items. 1 Quote Link to comment Share on other sites More sharing options...
anim Posted August 2, 2015 Share Posted August 2, 2015 don't use MMB to measure speed, use Performance Monitor MMB on wrangle will just show you time spent on Wrangle container itself, which is a subnet, if you dive inside you will see AttribVOP there, that's the node that does the work, MMB on that and you should see bigger number if you measure with Performance Monitor, you will get time as a sum of all the nested nodes, therefore you would see the real value that it took to execute Quote Link to comment Share on other sites More sharing options...
Zybrand Posted August 3, 2015 Share Posted August 3, 2015 Hey Atom, Another way you could write it in vex which is similar to what you had is the point sop is: float freq, amp; vector pos = @P; freq = chf("freq"); amp = chf("amp"); pos.x += sin(pos.y * freq) * amp; pos.z += cos(pos.y * freq) * amp; @P = pos; 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.