Procedurally generate a sine wave in a chramp?
369 6 1-
- toMilkman
- Member
- 6 posts
- Joined: 9月 2018
- オフライン
Hi everyone,
I want to use the chramp() function in VEX to drive an attribute, but I'd like the ramp's curve to be a perfect sine wave (similar to the attached image).
Manually clicking and adjusting points in the ramp interface is tedious and imprecise. Is there a way to procedurally or programmatically set the ramp's shape without doing it by hand?
Any tips would be greatly appreciated. Thanks!
I want to use the chramp() function in VEX to drive an attribute, but I'd like the ramp's curve to be a perfect sine wave (similar to the attached image).
Manually clicking and adjusting points in the ramp interface is tedious and imprecise. Is there a way to procedurally or programmatically set the ramp's shape without doing it by hand?
Any tips would be greatly appreciated. Thanks!
-
- tamte
- Member
- 9436 posts
- Joined: 7月 2007
- オフライン
If you want to procedurally define key positions and values use spline() [www.sidefx.com] or ramp_lookup() [www.sidefx.com] function
You can likely also just multiply sin() and -exp() functions for similar shape without having to sample any ramp
You can likely also just multiply sin() and -exp() functions for similar shape without having to sample any ramp
Edited by tamte - 2026年2月24日 02:50:30
Tomas Slancik
CG Supervisor
Framestore, NY
CG Supervisor
Framestore, NY
-
- animatrix_
- Member
- 5142 posts
- Joined: 2月 2012
- オフライン
Hi,
You can easily do this using Python:
You can easily do this using Python:
import math node = hou.pwd() parm_path = node.evalParm("parm_ref") parm = hou.parm(parm_path) if parm is None: raise hou.NodeError("Bad parm path in parm_ref: " + parm_path) N = 32 cycles = 1.0 phase = 0.0 amp = 0.5 offset = 0.5 decay = 0.0 keys = [i / (N - 1) for i in range(N)] vals = [] for t in keys: y = math.sin(2.0 * math.pi * cycles * t + phase) y *= math.exp(-decay * t) vals.append(offset + amp * y) basis = [hou.rampBasis.CatmullRom] * (N - 1) r = hou.Ramp(basis, keys, vals) parm.set(r)
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
-
- Konstantin Magnus
- Member
- 727 posts
- Joined: 9月 2013
- オフライン
Hi toMilkman,
you could also set one remap node to cyclically roll a wave-shaped ramp and another one to define the amplitude. Combine both with the attribute combine node.
you could also set one remap node to cyclically roll a wave-shaped ramp and another one to define the amplitude. Combine both with the attribute combine node.
Edited by Konstantin Magnus - 2026年2月24日 09:00:11
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
-
- toMilkman
- Member
- 6 posts
- Joined: 9月 2018
- オフライン
Hi tamte,
Thank you so much! I wasn't aware of those functions, so this is very helpful. I also appreciate you taking the time to provide the links.
I’ll definitely give them a try right away. I'm also interested in the sin() and -exp() approach, so I’ll be testing that out as well.
Thanks again for your help!
Thank you so much! I wasn't aware of those functions, so this is very helpful. I also appreciate you taking the time to provide the links.
I’ll definitely give them a try right away. I'm also interested in the sin() and -exp() approach, so I’ll be testing that out as well.
Thanks again for your help!
-
- toMilkman
- Member
- 6 posts
- Joined: 9月 2018
- オフライン
-
- toMilkman
- Member
- 6 posts
- Joined: 9月 2018
- オフライン
Hi Konstantin Magnus,
Thank you for the hip file! It's a very interesting approach, and I’ve learned a lot from it.
By the way, I’m a big fan of your YouTube channel. Thank you for uploading so many insightful tutorials; they are always incredibly helpful. I especially learned a lot from your recent tutorial on Smooth Tangential Boolean Unions.
I’m looking forward to your future content. Thanks again!
Thank you for the hip file! It's a very interesting approach, and I’ve learned a lot from it.
By the way, I’m a big fan of your YouTube channel. Thank you for uploading so many insightful tutorials; they are always incredibly helpful. I especially learned a lot from your recent tutorial on Smooth Tangential Boolean Unions.
I’m looking forward to your future content. Thanks again!
-
- Quick Links


