Your Ad Here

HLSL Programmable Shaders

This section describes how to set up XSI’s DirectX vertex and pixel shaders that use HLSL. You’ll find information about setting up HLSL vertex and pixel shaders, as well as an example of how to use them to create a per-pixel lit Phong shading effect in HLSL Programmable Shader Example: Per-Pixel Phong Lighting.

Programmable Shader Structure

A programmable shader has a very simple structure: it has input parameters, output parameters, and code. The code is called for every vertex of every pixel.

There are two types of input parameters: uniform and varying.

• Uniform means that the parameter value is the same for all vertices or pixels.

• Varying means that the parameter value changes for every vertex and every pixel.

SOFTIMAGE|XSI has shaders that allow you to specify program code and uniform parameters. Varying parameters are specified as part of the program code. For example, in the following code:

 

• The varying input parameter is the position of the vertex in object space (in green).

• The uniform input parameter is the model/view/projection matrix of the object (in cyan). This is used to transform the position from object space to screen space.

• The output parameters are the position of the vertex in screen space as well as its color (in yellow).

• Finally, the code computes the color and the position of the vertex in screen space (in magenta).



SOFTIMAGE|XSI v.6.01     

Return to Softimage XSI Index


Your Ad Here