Setting Up an Assembly Language Vertex Shader

DirectX-based shaders can also be programmed using assembly language. In general, you should use assembly language for very short programs or for programs that require precise control over how registers are assigned, and over the instructions used in your program.

This procedure shows you how to set up a vertex shader on an object using the DXVertexShader node.

1. Open a render tree (press 7) and connect a DX Draw shader (Nodes > RealTime > DirectX > More...) to the realtime port of the object’s Material node.

 

2. The next step is to connect a Dx Vertex Shader node (Nodes > RealTime > DirectX > More...).

3. Because the DX Vertex Shader node does not support semantics, you must set the constant registers using the DX Matrix (VS), DX Vector (VS), DX Color (VS), and/or DX Light Tracker shaders.

For this example, you need to set the model/view/projection matrix in the c0,c1,c2,c3 registers and the object’s color in the c4 register. Get the following shaders from the Nodes > RealTime > DirectX menu.

- A DX Matrix (VS) shader

- A DX Color (VS) shader

Connect all of the shaders as shown in the following image:

 

4. You can now open the DX Vertex Shader’s property editor and start typing your code. But first, take a look at the property page:

 

• The Build options allow you to do any one of the following:

- Disable the DX Program.

- Compile the program without executing it.

- Compile and execute the program.

• You can see compilation results from the script editor log window.

In the property editor shown above, the parameters were set as follows:

• A program was typed in the text box.

• The Build option was set to Compile and execute.

• The Profile was set to Vertex Shader 1.1.

5. To change the color of the object that this shade tree is applied to, open the DX Color (VS) node’s property editor and adjust the color sliders. For example, the settings in the following image make the object red.

 

Setting Vertex Shader Parameters

Now that you have your program code written, you have to set the values for the uniform parameters. Use the following shaders as needed:

DX Matrix (VS) sets values for 4 constant registers.

DX Vector (VS) and DX Color (VS) set values for a single constant register.

DX Light Tracker tracks lights’ information and sets it in constant registers.

To use these shaders, set the Constant Register that they operate on, and then set their values.



Autodesk Softimage v.7.5