Graphics Reference
In-Depth Information
// Vertex Shader input structure with position and color
struct VertexShaderInput
{
float4 Position : SV_Position;
float4 Color : COLOR;
};
// Vertex Shader output structure consisting of the
// transformed position and original color
// This is also the pixel shader input
struct VertexShaderOutput
{
float4 Position : SV_Position;
float4 Color : COLOR;
};
// Vertex shader main function
VertexShaderOutput VSMain(VertexShaderInput input)
{
VertexShaderOutput output = (VertexShaderOutput)0;
// Transform the position from object space to homogeneous
// projection space
output.Position = mul(input.Position, WorldViewProj);
// Pass through the color of the vertex
output.Color = input.Color;
return output;
}
// A simple Pixel Shader that simply passes through the
// interpolated color
float4 PSMain(VertexShaderOutput input) : SV_Target
{
return input.Color;
}
By default, Visual Studio will create the file using the UTF-8 with
signature encoding. The Direct3D 11 shader compiler requires ANSI
encoding. To do this in Visual Studio, navigate to FILE | Save Simple.
hlsl As... from the menu and select the Western European (Windows)
- Codepage 1252 encoding.
Select Yes when you are asked if you want to overwrite the file.
 
Search WWH ::




Custom Search