So I'm doing deferred shading and I need to draw a fullscreen quad/triangle in my vertex shader. I found this old topic (http://www.gamedev.net/topic/609917-full-screen-quad-without-vertex-buffer/) and used the vertex shader posted. For reference, here it is:
FullscreenTriangleVSOut main(uint VertexID: SV_VertexID)
{
FullscreenTriangleVSOut output;
output.mTexcoord = float2((VertexID << 1) & 2, VertexID & 2);
output.mPosition = float4(output.mTexcoord * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
return output;
}
I then added the following simple pixel shader:
float4 main(FullscreenTriangleVSOut input) : SV_Target0
{
return float4(1.0f, 0.0f, 0.0f, 0.0f);
}
I expected the whole window to be red, but it's just black.
Here's the other calls I'm doing to set this simple op up:
void DX11RendererImpl::ShadingPass(const RenderQueue& renderQueue)
{
mContext->OMSetRenderTargets(1, &mBackbuffer, mDepthStencilView);
mContext->OMSetDepthStencilState(mDepthStencilState, 1);
mContext->ClearRenderTargetView(mBackbuffer, gClearColor);
mContext->ClearDepthStencilView(mDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
// unbind all the buffers and input layout
mContext->IASetVertexBuffers(0, 0, NULL, 0, 0);
mContext->IASetVertexBuffers(1, 0, NULL, 0, 0);
mContext->IASetIndexBuffer(NULL, DXGI_FORMAT_R32_UINT, 0);
mContext->IASetInputLayout(NULL);
// the fxaa vertex shader and above posted pixel shader
mContext->VSSetShader(mVertexShader, NULL, NULL);
mContext->PSSetShader(mPixelShader, NULL, NULL);
mContext->Draw(3, 0);
DXCALL(mSwapchain->Present(0, 0));
}
Any ideas why this isn't drawing my whole screen in red?