Basic chramp question in VEX

   5483   13   0
User Avatar
Member
340 posts
Joined: June 2017
Offline
I am trying to replicate a simple attribute VOP in VEX, without all the overhead that I see in the VEX code from VOP. How can I assign a ramp to a parameter in VEX? Here is the file with a switch between VOP and Wrangle. I would like the attribute wrangle to replicate the VOP. The code I am using is:
float py = @ptnum/(@numpt-1.0);
float rampval = chramp(“ramp”, py);
@P.x=.075+rampval*@P.y;
Thanks.
Edited by Island - Aug. 16, 2020 12:33:53

Attachments:
Horn.hiplc (282.0 KB)
horn1.png (641.3 KB)

User Avatar
Member
340 posts
Joined: June 2017
Offline
I've also tried just @P.x=chramp(“ramp”,@P.y); and it too does not work.
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
You haven't actually created the ramp parameter “ramp”. You have to create it in order to reference it with your code:
float rampval = chramp(“ramp”, py);
User Avatar
Member
340 posts
Joined: June 2017
Offline
I thought ramp was a function, and you could click the “create spare parameter” to add the ramp. It seems like there should be a way to do this in VEX rather than depend on a VOP. The VEX code from the VOP suggests that there should a way.
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
I thought ramp was a function, and you could click the “create spare parameter” to add the ramp. It seems like there should be a way to do this in VEX rather than depend on a VOP. The VEX code from the VOP suggests that there should a way.

Not sure what your issue is. If you create the ramp parameter (gear icon) to your wrangle node…you get the same results like you have with your vop + nodes on the right of your network.

Edit: In your wrangle code you have to change the type of quotes for your ramp reference. Straight Double or single is fine but not curly.
Edited by BabaJ - Aug. 16, 2020 16:09:17
User Avatar
Member
340 posts
Joined: June 2017
Offline
Thank you for pointing out the curly quote issue. Changing them to straight double quotes does allow me to add a ramp parameter. Unfortunately, the ramp parameter doesn't seem to actually change the values, the way it does in the VOP assembly.

Attachments:
VEX.png (142.8 KB)

User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
That's because in your wrangle you left out dividing your ramp value by 5 - which you do in your VOP network.

Do this:

float rampval = chramp("ramp", @P.y) / 5.0;
User Avatar
Member
340 posts
Joined: June 2017
Offline
Thanks. I made an error above by omitting a decimal point which should be 0.2 multiplication (same as divided by 5) but the ramp still does not seem to work (regardless of whether the ramp is based on @P.y or @ptnum/@numpt):

float py = @ptnum/(@numpt-1.0);
float rampval = chramp(“ramp”, @P.y) / 5.0;
@P.x=.075+rampval;

(I am using straight quotes, but this forum seems to change to curly)
Edited by Island - Aug. 16, 2020 18:08:51
User Avatar
Member
1737 posts
Joined: May 2006
Online
I updated your scene, as other have said you were really close, it seems to be the directional double-quotes were breaking things. Changed to single quotes cos it's eaiser to type, and added the divide by 5 on the next line.

Attachments:
Horn_fix.hiplc (285.4 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
340 posts
Joined: June 2017
Offline
That is perfect. I'm trying to transition to VEX and need to understand it better. Thank you for all the help to those who responded! The VEX version is a lot less messy than the VOP.
Edited by Island - Aug. 16, 2020 19:48:29
User Avatar
Member
8539 posts
Joined: July 2007
Offline
Island
(I am using straight quotes, but this forum seems to change to curly)
so you better use code block when pasting any code, to match the VOP exactly you will need to base the ramp on v@P.y and not multiply by it afterwards

float rampval = chramp("ramp", clamp(@P.y,0,1));
@P.x=.075+rampval/5;
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
340 posts
Joined: June 2017
Offline
Thank you, tamte. That gives exactly the result I wanted.

Just out of curiosity, why did you use the clamp function rather than point number divided by (total points - 1)? Shouldn't they give the same result with a line? These give me exactly the same values:
f@test = @ptnum/(@numpt - 1.0);
f@test1 = clamp(@P.y,0,1);
Edited by Island - Aug. 17, 2020 00:31:52
User Avatar
Member
340 posts
Joined: June 2017
Offline
I do see that if I want to use @ptnum/(@numpt-1.0), there are some issues with integer to float conversions, and I need to write the attribute wrangle:

float rampval = chramp("ramp", 1.0*@ptnum/(@numpt-1.0));
@P.x=.075+rampval/5;
Edited by Island - Aug. 17, 2020 18:58:46
User Avatar
Member
8539 posts
Joined: July 2007
Offline
Island
Just out of curiosity, why did you use the clamp function rather than point number divided by (total points - 1)? Shouldn't they give the same result with a line?
I mean as long as the line is 0-1 in y then they are the same and also clamp() is not necessary
but since your VOP was using v@P.y I used v@P.y
and since Ramp Parameter VOP seems to automatically clamp the input I also clamped the value in VEX
because chramp() otherwise doesn't clamo the input and it would repeat the ramp for out of range values
so all the code was to simply match your VOP version, and not just for the current 0-1 line input
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links