User Guide > Shading > VEX Builder   

Creating a Color Shader

While Houdini ships with a number of Shader Operators (SHOPs) there are many other looks that you might want to achieve outside of this collection. These must be created by either coding in VEX or using the more interactive VEX builder.

The VEX builder lets you build up a shading network then publish this as a custom Shader operator (SHOP).


1. Set your Desktop

Select File > New. Select Desktops > VEX_builder. Make sure that in the Viewer pane, the Network type is set to VEX builder.

2. Create a Surface Shader

In the Network pane, press tab > Shader > VEX Surface Shader. Click in the pane to place the VEX operator (VOP). Change its name to color. With this selected, press i to go into the shader.

Press h to focus on the lone operator. This is the output operator that represents the final look of the shader. It has several input connections for you to attach other VEX operations. You can see in the shader ball that there is no shading defined yet.

3. Define the Lighting Model

In the Network pane, press tab > Materials > Lighting Model and click to place the operator. This operator lets you define the basic shading properties of your shader. In the Parameter pane, you can see a list of the lighting models available to you. Set Lighting model to Blinn.

Click on the lighting1 > color output and connect it to the ouput1 > Cf (surface color) input. The shader ball updates to show the qualities of the chosen lighting model.


Note: In the materials section of the tab menu, there are a number of high-level materials such as skin. These are more complex subnetworks and have a number of operators inside them that create these shading effects. Lighting model on the other hand is a starting point for building up your own network.

4. Create a Shader Operator (SHOP)

Press u to go up to the Surface shader level. In the Parameter pane, change the VEX Surface Shader field to color and the SHOP Type Name to Color Shader. RMB-click on the surface shader operator and select Create New SHOP.

Select Network > Shaders (SHOP) to see the new shader. This can be assigned to objects. One thing you will notice is that there are no parameters for this shader. This is because Parameters need to be published using special parameter operators.

5. Add Parameter VEX Operators

RMB-click on the new color shader and select Edit VOP Network. MMB-click on the diff input for the lighting operator and select Create Parameter from the menu. Now this parameter will be published to the SHOP level. Repeat for the lmodel, spec,urough and vrough parameters. You can decide which parameters are published to artists and which are not.

Press u to go up to the surface shader level. In the Parameter pane, you can re-order the parameters to suit how you want them presented at the SHOP level.

6. Go Back to the SHOP level

Select Network > Shaders (SHOP) to go to the updated shader with parameters available for artist control.

Conclusion

The VEX builder lets you create shader code using an interactive approach. TDs can build shaders with complex networks then publish only those parameters that are needed to give the artist the ability to make creative decisions.