Справка Houdini на русском Nodes VOP nodes

Inline Code VOP node

Write VEX code that is put directly into your shader or operator definition.

On this page

This operator lets you write VEX code that is put directly into your shader or operator definition.

Up to 64 inputs can be connected to this operator, and they can be of any data type. You can also use the parameters of this operator to define up to 32 outputs that can also be of any data type, and be given any name.

When writing your inline VEX code, you do not need to write variable declarations for any of the inputs or outputs to the operator. Any extra variables that you do declare should be prefixed with a $. This tells the VOPNET code generator that it is a variable name, and should be made unique. Similarly, when referring to input or output variables, their names should be prefixed with a $, or the code generator will not use the correct variable names. Do not use the $ prefix for global variable names.

The $ is needed if you are going to instantiate more than one copy of your VOP in the same shader. Without the $ before variable names, the variables will be declared with the same name in different Inline VOPs, resulting in the same value being referenced in each VOP. This sharing of values between VOPs is normally not wanted, so the $ makes a new version of the declared variable in each instance of the VOP.

Although it is possible to assign values to input variables, it is strongly discouraged. There is no guarantee made about the order in which VOPs will generate their code, so assigning values to input variables may give unpredictable results.

You should use this operator only if you are familiar with VEX programming. It is very easy to introduce errors into your code using this operator. If there are errors in your code, you will be able to see what they are by middle-clicking on the icon of any VOP in the network.

As an example, the following inline code will output the length of the hypotenuse of a right angle triangle, if the Inline VOP node has two inputs named in1 and in2 and an output named out1:

$out1 = sqrt($in1 * $in1 + $in2 * $in2);

Note

The input names are found in the Name column. For example, in this illustration the second input is referred to as $freq, since it’s second in the list. Similarly the fifth input is $scale, since it is fifth in the list.

Parameters

Inline VEX Code

This parameter is where you write the VEX code that is to be put in your shader.

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 in the Inline VEX Code parameter. This is simply a list of files, such as voplib.h shading.h.

Outer Code

This parameter specifies any VEX code that should appear outside (before) the shader function definition.

Expand Expressions in Code

Since the $ has to be used for prefixing variables to avoid variable name conflicts with other VOP nodes, no expression evaluation is normally done in the Inline VEX Code or Outer Code parameters. However, this means that chsraw() references won’t work to pull in code snippets from elsewhere. This option turns on the expression evaluation.

Input Name/Label

For each input connected to this operator you can specify the name and label for the input. To change the name or label for an input, enter the new string directly in the table presented. If an empty string is specified in the table, the name and label will be copied from the operator connected to each input.

Output N Type, Name, and Label

These parameters specify the name, label, and data type for each output you wish to define.

Inputs

Next Input

Where the next input value should be connected. Up to 64 inputs can be specified.

Examples

CrinkleSphere Example for Inline Code VOP node

This example demonstrates the use of an Inline Code node that allows you to write VEX code that is put directly into your shader or operator definition.

Скачать пример

The following examples include this node.

CrinkleSphere Example for Inline Code VOP node

See also

VOP nodes