CompilingVEXCode
From Odwiki
This page describes how to use hand-written VEX code. For beginners, please consult the regular documentation on using VOPs instead.
Building From VEX code
- Write your code:
#pragma opname test #pragma oplabel "Test Compilation" #pragma label Cd "Surface Color" #pragma hint Cd color surface test ( vector Cd = 1;) { Cf = Cd; }and save it to a file (say, "test.vfl"). - Compile and create an OTL (which builds a dialog for our shader, using those #pragmas that we put in there, as well as the default data-type UI). Go to where you saved "test.vfl" and type:
vcc -l test.otl test.vfl
If compilation succeeded, then you should see an OTL file called "test.otl" alongside your original source file "test.vfl". - Start Houdini and go to "File>Install Operator Type Library..." and load the otl we just created (test.otl). Go to /shop and TAB>"te" -- you should see the "Test Compilation" shader in the tab menu. Use it as you would any other shader (e.g: drag-and-drop onto your object in the viewport).
Adding Inline Code Using the Inline VOP
The contents of the InlineVOP are inserted into the body of the context function (e.g: the body of the actual shader in the surface-shading context). The only caveat is that you should precede any local variable names with a dollar sign ($) -- this is to avoid name clashes when Houdini builds the vex code. So:
- Start Houdini and go into /vex (or the "VEX Builder" desktop if you prefer). TAB-add a "VEX Surface Shader" operator. Call it "inlinetest", and set its "SHOP Type Name" parameter to "Inline Test". Go into it (press Enter). You'll see an Output VOP called "ouput1" in there -- ignore it for now.
- Add a Parameter VOP (TAB>"par">Enter) with:
Parameter Type -> Color
Parameter Name -> "Cd" (no quotes)
Parameter Label -> "Surface Color" (no quotes)
Color>Color Default -> 1 1 1 - Add an Inline VOP with:
Output 1 Type -> Vector
Output 1 Name -> "col", "col" (no quotes) - Connect the "Cd" output of the ParameterVOP to the first input of the Inline VOP (labeled "next"). Select the inline vop, click on the "Inline VEX Code" field, and type Alt+e to bring up the text editor.
- In the test editor's top pane, type:
$col = $Cd;
and hit Accept to dismiss the editor and accept its contents. - Connect the "col" output of the InlineVOP to the "Cf" input of the OutputVOP (all shaders have a fixed Output VOP -- you don't add that one yourself, it's added for you).
- RMB on any one of the VOPs you just created and from the popup menu select "Create New Shop From VOP Network". Now go to /shop and you should see a new "inlinetest1" shop. Use as you would any other shader.



