运行一个VEX代码段来修改输入的值。
Overview
这是一个非常强大的,低级别的节点,可以让熟悉VEX的专家使用代码来修改属性。
这个节点和Point Wrangle SOP类似(以及其它wrangle节点), 可以使用VEX代码段操纵几何体。
Warning
这个节点要求你理解VEX语言 。 使用该节点很容易编写正确的代码。
这个节点会在计算节点时,允许代码段。属性线中的值可以使用VEX变量来获取。代码段可以修改变量,然后将数值传输到节点的输出端。每个输入端都有相应的输出端,不管代码段是否修改其值。
如,如果你有一个变量名为foo,你可以写这样的代码:
foo *= 2
…and the foo output will have double the value of the foo input.
Press on the node to see any error output from the snippet.
You can use the VEX function ch to evaluate parameters. The path is relative to this node (ch(“parm”) will evaluate the parameter parm on this node). This evaluation will be done at the current time.
Creating inputs
The node has a “multi-input” that can accept any datatype wire. Wiring into this input creates a new input on the node. You can then use the value of the input by referencing its internal name as a variable. You can hover over a VOP node input/output to see its internal name.
You can rename an input by number to a fixed name using theVariable name # parameters. For example, you can say the first input will map to the variable foo. This allows you to rewire the input without having to change your code.
It’s possible to read and write global variables directly (for example, P and Cd in the SOP context). However, we strongly recommend you don’t use global variables directly. Houdini does not guarantee the order in which VOPs generate their code, so assigning values to globals can give unpredictable results. Instead, you should explicitly wire from the globals node into this node.
Unlike the Inline VOP, you do not prefix variables with $. (The snippet will be encapsulated in a function definition.)
Binding geometry attributes to VEX variables
In the SOP context and CVEX shaders applied to geometry, you will usually want to read and write geometry attributes in the snippet. The best way to access geometry attributes is by wiring a Bind VOPinto this node.
However, in some cases, you may want to promote snippet parameter while the VOP network is locked, preventing the user from binding variables. In this case, the user can access attributes using the@ syntax explained below.
Syntax
The VEX snippet parameter lets you enter a snippet of VEX code to run on the input geometry. See VEX snippets for information on special syntax in the snippet parameter. See the VEX chapter form information on the VEX language.
Parameters
Code Snippet | A snippet of VEX code that will manipulate the point attributes. You can use @variable_name syntax to access geometry attributes. |
Include Files | List any files that need to be included at the start of your shader. You can use this facility to write complex functions, and then call them with a single line of VEX code. This is simply a list of files, such asvoplib.h shading.h. |
Outer Code | This parameter specifies the source code that should appear outside (before) the shader function definition. |
Expand Expressions in Code | If you wish to use $ for temporary variables, you have to prevent the expansion of variable names or your temporaries will be expanded. However, using $ is not recommended. |
Variable Name # | For each input connected to this operator you can specify the name for the input. If an empty string is specified in the table, the name will be copied from the output connected to each input. This will be the name used inside the code snippet to both read from the input and write to the output. |
Bindings to Export | When an ad-hoc binding is created with the @ syntax, it is brought in as a read-only parameter to the generated VEX function. If it matches this string, however, it will be flagged as an export. In VOP SOP contexts, for example, this will cause it to create a new attribute. |
Inputs
Next Input | Where the next input value should be connected. Each input will create a corresponding output |