You got plenty of possibilities:
- Use the transformation matrices. Though it's 2D the same logic applies, i.e. use the so-called world transformation to position and scale your quad.
- Set up a vertex buffer covering the whole screen (clip space from -1 to 1 for both x and y, z = 0, w = 1) and just pass them through in the vertex shader
- For a fullscreen quad you don't even need transformations or vertex buffers at all. You can setup a vertex shader which generates the position/texcoords automatically, see below.
void FullScreenTriangleFromIndex(uint index, out float4 position, out float2 tex)
{
tex = float2((index << 1) & 2, index & 2);
position = float4(tex * float2(2,-2) + float2(-1,1), 1, 1);
}
// Call with Draw(3,0)
void FullScreenTrianglePositionOnlyVS(uint id : SV_VertexID,
out float4 position: SV_Position)
{
float2 tex;
FullScreenTriangleFromIndex(id, position, tex);
}
void FullScreenTrianglePositionTexVS(uint id : SV_VertexID,
out float4 position: SV_Position,
out float2 tex: TEXCOORD)
{
FullScreenTriangleFromIndex(id, position, tex);
}
static uint fsqids[] = {0,1,2,1,3,2};
void FullScreenQuadFromIndex(uint index, out float4 position, out float2 tex)
{
uint id = fsqids[index];
tex = float2(id & 1, (id >> 1) & 1);
position = float4(tex * float2(2,-2) + float2(-1,1), 1, 1);
}
// Call with Draw(6,0)
void FullScreenQuadPositionOnlyVS(uint id : SV_VertexID,
out float4 position: SV_Position)
{
float2 tex;
FullScreenQuadFromIndex(id, position, tex);
}
void FullScreenQuadPositionTexVS(uint id : SV_VertexID,
out float4 position: SV_Position,
out float2 tex)
{
FullScreenTriangleFromIndex(id, position, tex);
}