Time for action – Vertex Shader Input and Output definition
1. Modify the declaration for the
VertexShaderInput
struct
by adding an entry for a texture coordinate. The newstruct
should be as follows:struct VertexShaderInput { float4 Position : POSITION0; float2 TextureCoordinate : TEXCOORD0; };
2. Similarly, modify the declaration for the
VertexShaderOutput
function in the same way:struct VertexShaderOutput { float4 Position : POSITION0; float2 TextureCoordinate : TEXCOORD0; };
What just happened?
The VertexShaderInput
structure is passed to our vertex shader function, which we will be modifying in the next section. The return value of the vertex shader is a VertexShaderOutput
structure. This is similar to what we would do with C# to define the type of data we are passing into a function and specifying what type of information it returns.
The default shader code already has the Position
field, which is declared as a float4
. Once again, thinking back to our discussion on matrices...