I need to render a full screen quad, until now I have been using this:
FLOAT fWidth5 = ( FLOAT )dtdsdRT.Width - 0.5f; FLOAT fHeight5 = ( FLOAT )dtdsdRT.Height - 0.5f; // Draw the quad QuadVertex svQuad[4]; svQuad[0].Position = D3DXVECTOR4( -0.5f, -0.5f, 0.5f, 1.0f ); svQuad[0].Texture = D3DXVECTOR2( fLeftU, fTopV ); svQuad[1].Position = D3DXVECTOR4( fWidth5, -0.5f, 0.5f, 1.0f ); svQuad[1].Texture = D3DXVECTOR2( fRightU, fTopV ); svQuad[2].Position = D3DXVECTOR4( -0.5f, fHeight5, 0.5f, 1.0f ); svQuad[2].Texture = D3DXVECTOR2( fLeftU, fBottomV ); svQuad[3].Position = D3DXVECTOR4( fWidth5, fHeight5, 0.5f, 1.0f ); svQuad[3].Texture = D3DXVECTOR2( fRightU, fBottomV ); DWORD oldZ; gEngine->GraphicsDevice()->GetDeviceCOM()->GetRenderState( D3DRS_ZENABLE, &oldZ ); if (oldZ) gEngine->GraphicsDevice()->GetDeviceCOM()->SetRenderState( D3DRS_ZENABLE, FALSE ); gEngine->GraphicsDevice()->GetDeviceCOM()->SetFVF( D3DFVF_XYZRHW | D3DFVF_TEX1 ); gEngine->GraphicsDevice()->GetDeviceCOM()->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, svQuad, sizeof( QuadVertex ) ); if (oldZ) gEngine->GraphicsDevice()->GetDeviceCOM()->SetRenderState( D3DRS_ZENABLE, TRUE );
Which works just fine but does not go through the shader because of the D3DFVF_XYZRHW value.
So I tried to use XYZ and XYZW but both gave me incorrect results. I also tried rendering the quad at size of [0,1] and sizes [-1,1] as I saw online some discussions, both failed, also [0,width/height] seems to have failed, but I may have not tried XYZ or XYZW in one or the other.
What is the solution for this ? How should I make my vertices so I can have a fullscreen quad which will also go through the vertex shader (the reason for it to go through the vertex shader is because I need a corner index of the quad to pass values to the pixel shader, so my texture UV is actually D3DXVECTOR3 with z being the index).






