I am totally confused right now when I use sample the screen is simply red, but the general problem persists.
Why is Load only returning the red value?
the color variable always just receives the red value and the rest are underscores in pix...
The shader with vertex shader
float4 VSMain(in float3 Position : POSITION) : SV_Position
{
return float4(Position, 1.0f);
}
float PSDisabledMain(in float4 screenPos : SV_Position) : SV_Target0
{
//BackBufferMap.Sample(TexureSampler, screenPos.xy);
int3 sampleIndices = int3(screenPos.xy, 0);
float4 color = BackBufferMap.Load(sampleIndices);
return color;
}
The vertices used:
glm::vec3 vertices[] =
{
glm::vec3(-1.0f, -1.0f, 0.0f),
glm::vec3(-1.0f, 1.0f, 0.0f),
glm::vec3( 1.0f, -1.0f, 0.0f),
glm::vec3( 1.0f, 1.0f, 0.0f),
};
The vertices and Load function is simply the same I am using in my deferred rendering shaders...
And here's how I create the backbuffer:
D3D11_TEXTURE2D_DESC backTextureDesc;
D3D11_RENDER_TARGET_VIEW_DESC backTargetViewDesc;
D3D11_SHADER_RESOURCE_VIEW_DESC backResourceViewDesc;
ZeroMemory(&backTextureDesc, sizeof(backTextureDesc));
backTextureDesc.Width = width;
backTextureDesc.Height = height;
backTextureDesc.MipLevels = 1;
backTextureDesc.ArraySize = 1;
backTextureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
backTextureDesc.SampleDesc.Count = 1;
backTextureDesc.Usage = D3D11_USAGE_DEFAULT;
backTextureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
backTextureDesc.CPUAccessFlags = 0;
backTextureDesc.MiscFlags = 0;
HR(m_d3dDevice->CreateTexture2D(&backTextureDesc, NULL, &m_BackTargetTexture));
backTargetViewDesc.Format = backTextureDesc.Format;
backTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
backTargetViewDesc.Texture2D.MipSlice = 0;
HR(m_d3dDevice->CreateRenderTargetView(m_BackTargetTexture, &backTargetViewDesc, &m_BackTargetView));
backResourceViewDesc.Format = backTextureDesc.Format;
backResourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
backResourceViewDesc.Texture2D.MostDetailedMip = 0;
backResourceViewDesc.Texture2D.MipLevels = 1;
HR(m_d3dDevice->CreateShaderResourceView(m_BackTargetTexture, &backResourceViewDesc, &m_BackResourceView));