Graphics Reference
In-Depth Information
};
struct PixelIn
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
2.
Add a new vertex shader passing through the input positions unchanged,
and calculate the UV coordinates from these:
// Screen-Aligned Quad: vertex shader main function
PixelIn VSMain(VertexIn vertex)
{
PixelIn result = (PixelIn)0;
// The input quad is expected in device coordinates
// (i.e. 0,0 is center of screen, -1,1 top left, 1,-1
// bottom right). Therefore no transformation!
result.Position = vertex.Position;
result.Position.w = 1.0f;
// The UV coordinates are top-left 0,0 bottom-right 1,1
result.UV.x = result.Position.x * 0.5 + 0.5;
result.UV.y = result.Position.y * -0.5 + 0.5;
return result;
}
3.
Create a new C# class, ScrenAlignedQuadRenderer , descending from
Common.BaseRenderer , and add the following private and public members
and default constructor:
public class ScreenAlignedQuadRenderer :
Common.RendererBase
{
// The vertex shader
VertexShader vertexShader;
// The vertex layout for the IA
InputLayout vertexLayout;
// The vertex buffer
Buffer vertexBuffer;
// The vertex buffer binding
VertexBufferBinding vertexBinding;
 
Search WWH ::




Custom Search