Skip to content

Instantly share code, notes, and snippets.

@Inori
Forked from rorydriscoll/FullScreenQuad.hlsl
Created April 18, 2020 22:42
Show Gist options
  • Save Inori/6660d3b4d979baebe9c5b3a97ea19b0c to your computer and use it in GitHub Desktop.
Save Inori/6660d3b4d979baebe9c5b3a97ea19b0c to your computer and use it in GitHub Desktop.
A vertex shader that uses the vertex ID to generate a full-screen quad. Don't bind vertex buffer, index buffer or input layout. Just render three vertices!
struct Output
{
float4 position_cs : SV_POSITION;
float2 texcoord : TEXCOORD;
};
Output main(uint id: SV_VertexID)
{
Output output;
output.texcoord = float2((id << 1) & 2, id & 2);
output.position_cs = float4(output.texcoord * float2(2, -2) + float2(-1, 1), 0, 1);
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment