A shader is a small program that runs on the GPU to create rendering effects that would be difficult or impossible to implement using the fixed-function pipleine. Visualize supports custom shaders in the DirectX9, DirectX11, and OpenGL2 drivers. Shaders must be written in HLSL. Instructions for authoring HLSL is beyond the scope of this document, however, once the shader is written, it is simple to use in Visualize by following the steps below:
The shader source can be read from a file or passed to Visualize as a UTF-8 encoded string (C# users can simply use String).
In Visualize, shaders live in portfolios, and portfolios are referenced by segments. Thus, if the geometry is to use a shader, it must be in a segment which uses the portfolio (portfolios are inherited down the segment tree like other attributes). The only way to define a shader is by using a HPS::ShaderKit.
The last step is to set the segment's geometry to use the shader for the face material. In the example below, a shell is used to demonstrate an effect that would be cumbersome to produce using other methods. While this example is trivial, shaders can be extended to produce complex effects.