toMilkman
Feb. 24, 2026 00:51:57
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!
tamte
Feb. 24, 2026 02:44:04
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
animatrix_
Feb. 24, 2026 03:13:11
Hi,
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)
Konstantin Magnus
Feb. 24, 2026 08:59:58
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.
toMilkman
Feb. 25, 2026 02:16:45
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!
toMilkman
Feb. 25, 2026 02:19:27
Hi animatrix_,
That’s exactly what I was looking for! Thank you so much for taking the time to write the Python script for me. It’s incredibly helpful.
I’ll put it to use right away. I really appreciate your help!
toMilkman
Feb. 25, 2026 02:26:07
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!