On this page |
Overview ¶
Houdini supports RGB color ramps and floating point (spline) ramps. One varies color along the length of the ramp, creating a gradient, and the other varies a single value, creating a curve.
Tip
For smooth curves, evenly space the control points.
Interpolation for all points
The following ramps set the interpolation for all points, which controls how Houdini fills in the values between points.
Constant
Creates a ramp in the shape of a constant curve.
Linear
Creates a ramp in the shape of a straight line.
Catmull-Rom
Creates a ramp in the shape of a Catmull-Rom curve.
Monotone Cubic
Creates a ramp in the shape of a monotone cubic curve.
Bezier
Creates a ramp in the shape of a Bezier curve.
B-spline
Creates a ramp in the shape of a B-spline curve.
Hermite
Creates a ramp in the shape of a Hermite curve. In a Hermite ramp, the curve passes through the odd control points and the even points control the tangent at the previous point.
Reverse Domain
Flips the points in the ramp along the x-axis.
Complement Ramp
Flips the points in the ramp along the y-axis.
Presets
Preset configurations you can apply to the ramp.
Grayscale View
Displays a grayscale background on the floating point ramp. The color of the background matches the value of the ramp at that point. In this mode, you can open a color editor to edit the values of the ramp’s points (see Using a ramp parameter).
Point No.
The number of the selected point.
Position
The position of the selected point in the ramp.
Color
The color of the selected point. See Using a ramp parameter for more information about how to open the color ramp’s color editor.
Value
The value of the selected point.
Interpolation
Sets the interpolation of the ramp on a point-by-point basis, which controls how Houdini fills in the values between the selected point and the next point. Instead of this method, it’s recommended that you set the interpolation for all points (see Interpolation for all points).
Using a ramp parameter ¶
To... | Do this |
---|---|
Select an existing point |
Click the arrow-shaped point handle on the bottom of the ramp for the point you want to select. Tip For a floating point ramp, you can also click the in the ramp. or
Set the Point No. parameter to the number of the point you want to select. |
Create a point |
Click in the ramp area where you want to create a new point. or
Click the Add Point button. The point is added after the currently selected point. |
Delete a point |
Select a point and then click the Remove Point button. |
Change a point’s position |
Select a point and then set the Position parameter to a specific position. or
Drag an arrow-shaped point handle left or right to move the point. Tip For a floating point ramp, you can also drag the left or right in the ramp. |
Change a point’s value in the floating point ramp |
Select a point and then set the Value parameter to a specific value. or
Drag the up or down to adjust the point’s value. |
Open the ramp’s color editor |
|
Hide/show parameters |
|
Maximize/minimize the floating point ramp |
|
Reading a ramp parameter ¶
Expression language
Use the chramp, chrampt, and chrampf functions to read a value from a ramp parameter in an expression.
To read the value from a ramp at the current time:
chramp(‹ramp_path›, ‹position›, ‹component_index›)
Where ‹ramp_path› is the path to the ramp parameter you want to read, and ‹position› is the position along the ramp at which to read the value (from 0 to 1). For color ramps, you must also specify the ‹component_index›, i.e. red = 0
, green = 1
, or blue = 2
. For spline ramps, use 0
as the third argument.
chrampt
lets you read a value from a ramp at a specific time. chrampf
lets you read a value from a ramp at a specific frame.
HOM
To read the value of a ramp parameter:
-
Get a reference to the hou.Parm object representing the parameter.
-
Call the tuple method on the object to get its hou.ParmTuple value.
-
Call one of the eval, evalAsRamp, or evalAsRampAtFrame methods on the
ParmTuple
object to get a hou.Ramp object.
You can also call the parmTemplate method on the Parm
object to get a hou.RampParmTemplate object containing metadata about the parameter (i.e. its default values).
# Grab a reference to a ramp parameter. # This is a hou.Parm object just like any # other parameter. >>> r = hou.parm("/obj/my_character/gradient") >>> r <hou.Parm gradient in /obj/my_character> # Get "parm tuple" for this parameter, and # evaluate it at the current time. Whereas # evaluating a floating-point parameter would # return a float value, and evaluting a # textbox would return a string, evaluating # a ramp parameter returns a hou.Ramp object. >>> ramp = r.eval() >>> ramp <hou.Ramp is_color=True num_keys=2 ... > # You can then use the lookup() method to # get a value from the ramp. This returns # a tuple or float depending on the type # of ramp. >>> ramp.isColor() True >>> ramp.lookup(0.5) (0.1, 0.5, 0.8)
VEX
See ramp parameters on VEX shaders below.
Adding a ramp parameter to a node ¶
The color and floating point ramp parameter types appear in the list of available parameter types as Ramp (Color)
and Ramp (Float)
when you edit a digital asset definition or directly edit the parameter interface of a single node.
See how to edit a digital asset or how to edit a node’s parameter interface.
Ramp parameters on VEX shaders ¶
In a VOP network ¶
To add a ramp parameter to a shader in a VOP network:
-
Create a Ramp Parameter node.
-
In the parameter editor, choose the Ramp type (RGB Color ramp or Spline ramp).
-
Connect a float output to the ramp parameter’s input. The input controls the position in the ramp to output.
For example, you could create a Global Variables node and connect its
s
output to the ramp’s input, so the ramp node’s output varies across the S direction of the surface. -
Connect the ramp parameter node’s output to a Color or Vector input (for the RGB ramp) or a Float input (for the Spline ramp) on another node.
In VEX code ¶
The ramp_rgb and ramp_flt pragmas create a ramp parameter in the UI from three arguments to the shader function.
-
An array of strings representing the interpolation basis between each key.
-
An array of floats representing the position of each key along the ramp.
-
An array of vectors (for a color ramp) or floats (for a spline ramp) representing the value of each key.
In code generated by VOPs, the keys are made linear using spline with the "solvelinear"
keyword and the index (in the code below, 0.5
), and then the arrays and the “uniform-ized” index are passed to the spline function.
(If in your own code you already are guaranteed to have uniform key positions, you can use ""
as the key positions argument to the pragma, and skip the “solvelinear” step and just use the index as the second argument to the outer spline
call.)
#pragma ramp_rgb ramp2 ramp2_the_basis_strings ramp2_the_key_positions ramp2_the_key_values #pragma label ramp2 Gradient #pragma parmtag ramp2 rampbasisdefault catmull-rom surface vopsurface1(string ramp2_the_basis_strings[]={"linear","linear"}; float ramp2_the_key_positions[]={0,1}; vector ramp2_the_key_values[]={{ 0, 0, 0 },{ 1, 1, 1 }}) { vector ramp21; // Code produced by: rampparm1 ramp21 = spline(ramp2_the_basis_strings, spline("solvelinear", 0.5, ramp2_the_key_positions), ramp2_the_key_values); ...