Home Reference VEX 

vcc compiler pragmas

Tags: vcc

The VEX compiler (vcc) supports pragmas for automatically building UI dialog scripts. These pragmas are typically ignored unless the -u option is specified on the vcc command line. The pragmas let you specify help, hints for how to represent the parameter, organization, and other information.

#pragma bindhandle

#pragma bindhandle channel_name h_name h_label h_index h_settings

Binds handles to specific parameters by default (users can override bindings).

channel_name

The name of the channel in the VEX operator to bind to the handle.

h_name

Handle name. This is one of the pre-defined Houdini handles (for example ladder). You can use the omls HScript command for a full list of available handles.

h_label

A brief description of the handle.

h_index

Many handles (for example xform) have multiple parameters associated with them. This allows you to choose which handle parameter gets bound to the VEX parameter.

h_settings

An optional handle-specific string that can be used to set some default behavior for the handle.

#pragma bindhandle offset1 xform "Translate" tx "invisible(1)"
#pragma bindhandle offset2 xform "Translate" ty
#pragma bindhandle offset3 xform "Translate" tz
sop translate(vector offset=0) { P += offset; }

#pragma bindhandlereserved

#pragma bindhandlereserved reserved_channel_name h_name h_label h_index h_settings

Each scripted operator type has a number of parameters that are added to every operator of that type (regardless of the contents of the dialog script file). To bind a handle to one of these parameters, you must use the bindhandlereserved pragma. This pragma takes exactly the same arguments as the bindhandle pragma. The only exception is that the channel name argument must specify the name of a reserved parameter.

#pragma bindselector

#pragma bindselector [parm_name] sel_type sel_name sel_prompt sel_mask allow_dragging group_type_parm asterisk_sel_all [input_index input_required]

When an operator is created interactively in Houdini, the user can be prompted for the data to work on. These prompts are handled by selectors. Selectors can be defined on a per-OP basis, or a per-parameter basis.

For per-OP selectors, the bindselector pragma expects 7 arguments. For per-parameter selectors, it expects 10 arguments.

parm_name

The VEX parameter to bind the selector to (for per-parameter selectors).

sel_type

The entity to select. Use the omsls HScript command to print a list of possible values.

sel_name

A brief description of the selector.

sel_prompt

the prompt presented to the user to select geometry.

sel_mask

a pattern which allows selection of specific primitive types. The list of possible primitive types are:

all

all primitive types

face

Polygons, NURBs or Bezier curves.

surface

Mesh, NURBs or Bezier surfaces

quadric

Primitive circles, spheres or tubes.

poly

Polygons

nurbscurve

NURBS curves

bezcurve

Bezier curves

mesh

Meshes

nurbs

NURBS surfaces

bezier

Bezier surfaces

circle

Primitive circles

sphere

Primitive spheres

tube

Primitive tubes

meta

Metaballs

particle

Particle systems

The primitive types can be combined in standard Houdini grouping mechanisms. For example:

  • all,^p*: select all primitive types except polygons and particles.

  • face,surface: select face and surface primitives.

  • *,^quad*,^meta: Select any primitive but quadrics or metaballs.

allow_dragging

If set to 1, the selection can be modified without forcing the user to click RMB to complete the selection.

This lets the user select and modify in one step (dragging with the mouse finishes selection and passes the mouse movements to the operator handles).

group_type_parm

The name of a parameter which indicates the geometry type the selection group will have. Typically this value will name a parameter with a menu for choosing “Points”, “Primitives”, or “Guess from group”. See the OMbindings file for the Blast SOP.

asterisk_sel_all

If set to 1, the selector needs to set the selection string to “*” to indicate all geometry was selected. If 0, the selector assumes an empty group parameter means all geometry was selected.

input_index

For per-parameter selectors. When the user selects geometry, the selector must connect the output from the selected operator to the input of this operator. This parameter specifies the index of the input number where the operator should be connected. Use -1 if the selector needs to connect multiple input operators into this operator.

input_required

For per-parameter selectors. Set to 1 if the user must select geometry for this input.

#pragma bindselector prims "Switch Geometry" \
"Choose the geometry to switch between" \
all 0 "" 0
#pragma bindhandle input_number 0 ladder Input parm0
sop switcher(int input_number=0) { import("P", P, input_number) }

#pragma bindselectorreserved

#pragma bindselectorreserved reserved_parm_name sel_type sel_name sel_prompt sel_mask allow_dragging group_type_parm asterisk_sel_all input_index input_required

Similar to the bindhandlereserved pragma, this binds selectors to reserved parameters in your scripted operators. The arguments to this pragma are the same as those passed to the bindselector pragma. The only difference is that the parameter name argument must specify a reserved parameter.

#pragma callback

#pragma callback name script

Binds an HScript script to parameter name. If the UI dialog script is bound to an operator (for example, a SHOP, SOP, POP, etc.), when the parameter changes, Houdini runs the associated script.

Because of architectural limitations in Houdini, the parameter and script must meet certain conditions:

  • The dialog script needs to be bound to a Houdini Operator (i.e. SHOP, POP, SOP, etc.).

  • The parameter must be either a toggle button, or have a menu bound to it (see #pragma hint and #pragma choice).

#pragma callback initialize_menu "sop/initialize_sop.cmd"

Houdini searches the standard $HOUDINI_PATH/scripts path for the script to run. If it finds the script, it sets the local variable $script_parm to the name of the parameter being changed, and runs the script.

#pragma crypt and #pragma endcrypt

#pragma crypt: The following lines should be encrypted .

#pragma endcrypt: Stop encrypting a block of code starting with #pragma encrypt.

#pragma crypt does not require a closing #pragma endcrypt. You can think of the two directives as turning encryption on and off.

#pragma disable

#pragma disable parm_to_disable control_parm control_value [control_parm2 control_value2 ...]

Disables parm_name when control_parm equals control_value

If you supply more than one pair of control parameters and values, parm_name is only disabled if all the conditions are true. To specify conditions where the parameter will be disabled if any one of them is true, use multiple pragma directives.

Disabling parameters helps make it clear to the user which parameters are useful in the current situation (for example, “Number of Subdivisions” is only useful when “Subdivide” is on).

// Disable parm B when A is 0 or A is 1:
#pragma disable B A 0
#pragma disable B A 1
// Disable parm C when A is 0 and B is 0, or just when A is 1.
#pragma disable C A 0 B 0
#pragma disable C A 1
// Disable parm D when C is "none".
#pragma disable D C "none"
cop2 function(int A = 0;
int B = 0;
string C = "gaussian";
vector D = { 0,0,0 })
{ ... }

#pragma export

#pragma export parm_name (none | dialog | all)

Adds the parameter UI to the operation parameters dialog, and optionally also the operator toolbar.

none or 0

No export. The parameter only appears in the operator’s standard dialog.

dialog or 1

The parameter appears in the operator’s parameter window.

all or 2

The parameter appears in the operator’s parameter window and the operator toolbar.

You can use #pragma hint hidden in combination with this pragma.

#pragma group

#pragma group group_name parameter_name1 parameter_name2 ...

Groups the named parameters into a tab in the UI.

// Group Ka, Kd, Ks, roughness into a folder called BRDF
#pragma group BRDF Ka Kd Ks
#pragma group BRDF roughness

Note

You can put / in your group name to create nested groups. For example, the following creates a Group tab with two sub-tabs.

#pragma group "Group/Sub Group 1" p1 p2
#pragma group "Group/Sub Group 2" p3 p4

#pragma help and #pragma info

#pragma help "text"

Adds text to the help in the dialog script. You can use this to document functions and parameters for end-users.

#pragma help "This is help for the VEX function."
#pragma help "It gets added automatically to the help text"

Like #pragma help, #pragma info text is added to the help in the dialog script. However, the info text is in a separate section at the beginning of the help. You can use this to specify copyrights, version information, etc.

#pragma info "Created by Bob Loblaw - (c) 2006"

Currently, only SOPs display info text.

#pragma hint

#pragma hint parameter_name hint_type

Adds information about what type of value a parameter represents (for example, a VEX vector may represent a point in space, a color, or a direction). The hint is used to specialize the UI for editing the value.

The hint_type can be one of the following:

none

No hint.

toggle

The integer or float represents an on/off switch (where 1 is on and 0 is off).

color

The parameter is a color. The UI will provide color sliders.

direction

The parameter is a direction. The UI will provide a gadget for specifying direction.

vector

The parameter is a 3D vector in space. The UI is the same as the default UI for a parameter with 3 floats, but the channel names will end with x, y, z instead of 1, 2, 3.

vector

The parameter is a 4D vector in space. The UI is the same as the default UI for a parameter with 4 floats, but the channel names will end with x, y, z, w instead of 1, 2, 3, 4.

UV

The vector parameter is UV coordinates. The UI is two entry fields instead of three (the third component passed to VEX is always 0), and the channel names will end with u, v instead of 1, 2.

UVW

The vector parameter is UV coordinates. The UI is two entry fields instead of three (the third component passed to VEX is always 0), and the channel names will end with u, v instead of 1, 2.

angle

The parameter is a direction vector. The UI will provide a direction gadget.

file

The string parameter is a filename. The UI adds a browser button for specifying the file. (See also image and geometry below.)

image

The string parameter is a filename of an image file. The UI adds a browser button for specifying the file, and the browser only displays image file types.

geometry

The string parameter is a filename of a geometry file. The UI adds a browser button for specifying the file, and the browser only displays geometry file types.

hidden

Generate no UI for this parameter. This is useful when you intend a parameter to be overridden by a geometry attribute.

invisible

The created parameter will exist in the operator but hidden from the user interface.

oplist [opfilter]

The parameter is a list of objects. You can optionally specify opfilter to limit the types of operators allowed in the list. Use #pragma parmtag to resolve any bundles or groups in the list of objects.

See the list of possible operator filters below.

oppath [opfilter]

The parameter is an object path. You can optionally specify opfilter to limit the types of operators that can be chosen.

See the list of possible operator filters below.

joinnext

Put the parameter after this one on the same row in the GUI. For narrow controls this can save space in the parameter editor.

Example: #pragma hint myParm joinnext

#pragma hint __nondiffuse toggle // Define as a toggle button
#pragma hint specularcolor color // This represents a color
#pragma hint rest hidden // Don't show rest parameter in UI
#pragma hint mapname image // This represents an image file
#pragma hint nullobject oppath "obj/null" // Only null objects

#pragma inputlabel

#pragma inputlabel inputnum "label"

For VEX operator types, sets the label for an operator input. This label appears when the user presses the middle mouse button on one of the operator inputs. The inputnum is the index of the input, starting at 1.

#pragma inputlabel 1 "Geometry to Modify"

#pragma label

#pragma label parameter_name "text"

Specifies a descriptive label for a parameter.

#pragma label amp "Noise Amplitude"
displacement bumpy(float amp=0) {
...
}

#pragma name “text”

Sets the label that appears in the UI. This pragma is obsolete since the label is now defined in the operator table definition.

#pragma opicon

#pragma opicon "text"

Use this pragma to set the icon to use for this operator type. It can be a path to an external .icon or .bicon file, or the name of one of the standard icons.

vcc’s -C command line option overrides this pragma.

#pragma opmininputs and #pragma opmaxinputs

#pragma opmininputs num

For VEX operator types, this sets the minimum number of inputs that must be connected to the operator. This value is ignored for SHOPs, which take no inputs. The operator will generate an error if fewer than this many nodes are connected as inputs. The -t command line option overrides this pragma.

#pragma opmaxinputs num

For VEX operator types, this sets the maximum number of inputs that can be connected to the operator. This value is ignored for SHOPs, which take no inputs. The -T command line option overrides this pragma.

#pragma opmininputs 1
#pragma opmaxinputs 4

#pragma opname and #pragma oplabel

#pragma opname "text"

Specifies the internal operator name of this operator type. By default the compiler uses the name of the source file. vcc’s -n command line option overrides this pragma.

#pragma oplabel "text"

Specifies a descriptive name for this operator type. By default the compiler uses internal operator name. vcc’s -N command line option overrides this pragma.

#pragma opname "myshop"
#pragma oplabel "My New Shop"

#pragma opshader

#pragma opshader"text"

If this operator type is a shader that can be used from renderers other than mantra, this pragma lets you set the name of the shader file that the renderer should look for. If you use this pragma, the operator type name does not need to match the shader file name. vcc’s -S command line option overrides this pragma.

#pragma opshader "rman_myshader"

#pragma parmhelp parameter_name “text”

#pragma parmhelp parameter_name "text"

Sets the tooltip that appears when the user hovers over parameter_name.

#pragma parmhelp amp "Increase this value to add more noise."
displacement bumpy(float amp=0) {
...
}

#pragma parmtag

#pragma parmtag parmName token value

Each parameter defined in an operator has a set of token/value tags associated with it. This pragma adds a token/value pair to a parameter.

The following tokens are available:

autoscope

A string of ones or zeros (for example “1011”) corresponding to each component of the parameter. 1 means the parameter is auto-scoped when the node is selected.

If there aren’t enough characters in the string for the number of components, the last character will be extended for the remaining components. This lets you specify “1” to autoscope all components and “0” to autoscope no components.

If this tag is not defined for a parameter, Houdini guesses if a parameter should be scoped or not.

opfilter

For parameters referring to object paths, this provides a filter for which types of OPs will be presented in the OP chooser. If you set this tag, you should also set the oprelative tag.

This tag is also set by the [#pragma hint oppath|/vex/pragmas] pragma, but using a different format.

Possible values are:

!!OBJ!!

Only show objects

!!OBJ/GEOMETRY!!

Only show geometry objects

!!OBJ/LIGHT!!

Only show light objects

!!OBJ/CAMERA!!

Only show camera objects (lights are considered cameras)

!!OBJ/BONE!!

Only show bone objects

!!OBJ/FORCE!!

Only show force objects

!!SOP!!

Only show SOPs

!!POP!!

Only show POPs

!!CHOP!!

Only show CHOPs

!!COP2!!

Only show COPs

!!VOP!!

Only show VOPs

!!ROP!!

Only show output drivers (ROPs)

!!DOP!!

Only show DOPs

!!SHOP!!

Only show SHOPs

!!SHOP/ATMOSPHERE!!

Only show atmosphere shader SHOPs

!!SHOP/BACKGROUND!!

Only show background shader SHOPs

!!SHOP/CONTOUR!!

Only show contour shader SHOPs

!!SHOP/CONTOUR_CONTRAST!!

Only show contour-contrast shader SHOPs

!!SHOP/CONTOUR_STORE!!

Only show contour-store shader SHOPs

!!SHOP/DISPLACEMENT!!

Only show displacement shader SHOPs

!!SHOP/EMITTER!!

Only show emitter shader SHOPs

!!SHOP/GEOMETRY!!

Only show geometry shader SHOPs

!!SHOP/IMAGE3D!!

Only show image3d shader SHOPs

!!SHOP/LENS!!

Only show lens shader SHOPs

!!SHOP/LIGHT!!

Only show light shader SHOPs

!!SHOP/LIGHT_SHADOW!!

Only show light-shadow shader SHOPs

!!SHOP/OUTPUT!!

Only show output shader SHOPs

!!SHOP/PHOTON!!

Only show photon shader SHOPs

!!SHOP/PHOTON_VOLUME!!

Only show photon volume shader SHOPs

!!SHOP/SURFACE!!

Only show surface shader SHOPs

!!SHOP/SURFACE_SHADOW!!

Only show surface-shadow shader SHOPs

oprelative

How paths should be resolved. Typically, the value of this token is “.” so that paths are resolved relative to the current operator. However, when referencing objects you can set the tag to “/obj”. See the example below.

opexpand

In SHOPs, causes “oplist” parameters to be expanded to the full path names. If a bundle or pattern is chosen, the pattern will be expanded before it’s sent to the renderer. See the example below.

opfullpath

When used in conjunction with the opexpand tag, causes the path names of the objects to be fully qualified rather than relative to the value of the oprelative tag. See the example below.

script_callback

The callback script associated with the parameter. See [#pragma callback|../guide/vex_pragmas_callback] .

script_ritype

Used when generating RIB streams and mapping the parameter to an appropriate renderman type specification. The value should be a valid renderman type (for example, “uniform color”).

script_unquoted

In VOP definitions, indicates the string parameter should be used in an unquoted form. This allows strings from menus to be placed verbatim in the code block (see the trig VOP).

sop_input

Used internally by SOPs to determine the place to search for groups when building a group menu of points/primitives.

#pragma parmtag lightmask opfilter "!!OBJ/LIGHT!!"
#pragma parmtag lightmask oprelative "/obj"
#pragma parmtag lightmask opexpand 1
#pragma parmtag reflectmask opfilter "!!OBJ/GEOMETRY!!"
#pragma parmtag reflectmask opexpand 1
#pragma parmtag reflectmask opfullpath 1

#pragma range

#pragma range parameter_name[!] min_value max_value[!]

Defines the ideal range for the parameter. If you append ! to a value, the parameter value will be clamped at that range. The UI also uses this information to set the range of the slider.

#pragma range seed 0 10
#pragma range roughness 0.001! 1!
#pragma range gamma 0.001! 10

#pragma rendermask

#pragma rendermask (VMantra | RIB | MI | OGL)

This pragma is only useful for SHOP dialog generation. Each SHOP has a mask defining which renderers can use the SHOP. It is possible to have a similar shader written in the RenderMan shading language and also in VEX (or another shading language). In this case, the rendermask can be specified to include more than just VMantra.

The rendermask parameter is closely bound to the code which generates scene descriptions for a renderer. Thus, the renderer names are quite specific. The renderers which support SHOPs are…

MI

Output generation for MentalRay compliant renderers.

RIB

RIB generation for RenderMan compliant renderers.

VMantra

The version of mantra which uses VEX for shading.

OGL

OpenGL rendering. This is a special renderer which automatically adds itself to most render masks. There is currently no way to prevent this.

How to create menus for parameters

You can define choice pragmas to create a menu UI for a parameter.

You build the list for a parameter by doing one of the following:

  • Use multiple choice pragmas for a parameter to create menu items (choice, choicescript, choicereplace, choicetoggle).

  • Use one or more choicescript pragmas for a parameter to create a script that creates the menu items (choicescript, choicereplacescript, choicetogglescript).

    This script is run whenever Houdini needs to generate the menu entries (i.e. the generated values are not cached) so this script should be as efficient as possible. The output of the script must be a series of value/label pairs, which have the same meaning as the value and label fields in the choice pragma.

The plain choice pragma creates a UI that only allows the user to choose values from the menu. The choicereplace pragma creates UI with a menu but also lets the user enter a different value manually. The choicetoggle pragma allows user input, but also provides a menu where choosing a menu item adds or removes it to/from the input.

menu or input their own.

menu or input their own.

the user input.

the user input.

Pragma Generation UI

#pragma choice parameter_name "value" "label"

Adds a menu item for parameter_name.

Provides a menu of mutually exclusive choices.

#pragma choicescript parameter_name "scriptline"

Defines a line in a script that will generate menu items for parameter_name.

Provides a menu of mutually exclusive choices.

#pragma choicereplace parameter_name "value" "label"

Adds a menu item for parameter_name.

Provides a UI where the user can choose an item from the

#pragma choicereplacescript parameter_name "scriptline"

Defines a line in a script that will generate menu items for parameter_name.

Provides a UI where the user can choose an item from the

#pragma choicetoggle parameter_name "value" "label"

Adds a menu item for parameter_name.

Provides a menu of choices that add/remove items to/from

#pragma choicetogglescript parameter_name "scriptline"

Defines a line in a script that will generate menu items for parameter_name.

Provides a menu of choices that add/remove items to/from

#pragma choice operation "over" "Composite A Over B"
#pragma choice operation "under" "Composite A Under B"
#pragma choice operation "add" "Add A and B"
#pragma choice operation "sub" "Subtract A from B"
cop texture(string operation="over")
{
if (operation == "over") ... // texture coordinates
if (operation == "under") ... // parametric coordinates
if (operation == "add") ... // orthographic
if (operation == "sub") ... // polar
}
This would define a menu for the parameter “operation”. The menu would consist of 4 entries. The values for the string parameter would be one of “over”, “under”, “add” or “sub”. However, the user would be presented with more meaningful labels for the operation types.

#pragma choice operation "0" "Use texture coordinates"
#pragma choice operation "1" "Use parametric coordinates"
#pragma choice operation "2" "Orthographic Projection"
#pragma choice operation "3" "Polar Projection"
sop texture(int operation=0)
{
if (operation == 0) ... // texture coordinates
if (operation == 1) ... // parametric coordinates
if (operation == 2) ... // orthographic
if (operation == 3) ... // polar
}

Note

You can use pragmas other than choicereplace and choicetoggle to create menus for integer parameters, but the menu items ignore the labels and simply number the choices starting at 0. The choicereplace and choicetoggle pragmas are only valid for string parameters.

Operator list filters

These are the parameters you can use for the opfilter argument of certain pragmas.

obj

Any object.

sop

Any SOP.

pop

Any POP.

chop

Any CHOP.

cop

Any COP.

vop

Any VOP.

rop

Any ROP.

obj/geo

Any Geometry object.

obj/null

Any Null object.

obj/light

Any light.

obj/camera

Any camera.

obj/fog

Any Fog object.

obj/bone

Any bone.

shop/surface

Any surface SHOP.

shop/displace

Any Displace SHOP.

shop/interior

Any Interior SHOP.

shop/light

Any Light SHOP.

shop/shadow

Any Shadow SHOP.

shop/fog

Any Atmosphere SHOP.

shop/photon

Any Photon SHOP.

shop/image3d

Any Image3D SHOP.