How does this

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;

and this

pImmediateContext->VSSetShader(fxaaVS, ..., ...);
pImmediateContext->Draw(3, 0);

generate a Full Screen Quad?

  1. It has only three vertices b(provided quad has 4 vertices)
  2. the positions produced are also not like a (half of a) quad.

Looking at this, i might be confused between a quad and a full screen triangle.

  • 1
    \$\begingroup\$ It generates a fullscreen quad because it's a 'big triangle' that is clipped by the hardware to a quad. This is preferable because it avoids some duplicated work along what would otherwise be the diagonal seam if you draw it as two triangles. \$\endgroup\$ – Chuck Walbourn Mar 8 '18 at 17:36
  • \$\begingroup\$ Can you post this as an answer? Your comment answers my question \$\endgroup\$ – Basit Anwer Mar 9 '18 at 4:38
  • \$\begingroup\$ I think ratchet freak beat me to it :) \$\endgroup\$ – Chuck Walbourn Mar 10 '18 at 23:41

it doesn't generate a quad, instead it generates a fullscreen triangle.

The outputs end up as:

output[0].texcoord = float2(0,0); 
output[0].position_cs = float4(-1, 1, 0, 1);

output[1].texcoord = float2(2,0);  
output[1].position_cs = float4(3, 1, 0, 1);

output[2].texcoord = float2(0,2); 
output[2].position_cs = float4(-1, -3, 0, 1);

It goes beyond the edges of the screen but any part outside will get clipped by the rasterizer stage. Doing this avoid double coverage of evaluated pixel on the diagonal you get with 2 triangles.

| improve this answer | |
  • 1
    \$\begingroup\$ Be aware that both the 'self-generating quad' and the 'big triangle' rely on the VertexID system-generated value which requires Direct3D Hardware Feature Level 10.0 or better hardware if you are using Direct3D. See this blog post \$\endgroup\$ – Chuck Walbourn Mar 8 '18 at 17:37
  • \$\begingroup\$ DirectX 11 is the API... Direct3D Hardware Feature Level is what GPU is attached to the computer. Be sure you know the difference. \$\endgroup\$ – Chuck Walbourn Mar 10 '18 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.