In the meantime I have revised the shadow map DSV and SRV side of things.
int ShadowMapCreate2(int width, int height)
{
// Creating a render target so we can render the scene to this and use as a texture
D3D11_TEXTURE2D_DESC textureDesc;
ZeroMemory(&textureDesc, sizeof(textureDesc));
textureDesc.Width = width;
textureDesc.Height = height;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;
ID3D11Texture2D* renderTexture = NULL;
HRESULT result = d3dDevice->CreateTexture2D(&textureDesc, NULL, &renderTexture);
if (FAILED(result)) return 1;
D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
descDSV.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
descDSV.Texture2D.MipSlice = 0;
descDSV.Flags = 0;
if (FAILED(d3dDevice->CreateDepthStencilView(renderTexture, &descDSV, &d3dShadowMapDSV)))
return 2;
D3D11_SHADER_RESOURCE_VIEW_DESC descSRV;
descSRV.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
descSRV.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
descSRV.Texture2D.MostDetailedMip = 0;
descSRV.Texture2D.MipLevels = -1;
result = d3dDevice->CreateShaderResourceView(renderTexture, &descSRV, &d3dShadowMapSRV);
if (FAILED(result)) return 3;
renderTexture->Release();
return 0;
}
In doing so, I have gotten rid of the un-needed RTV. And am using a NULL pixel shader, during the depth map creation draw.
d3dContext->PSSetShader(NULL, NULL, 0);
As of yet it still hasn't changed the outcome. But I am hopefully getting closer each day.
@blicilidid confuse me with this though...
float4 shadowMapPixelShader(shadowPSInput_s input) : SV_TARGET
{
float z = input.position.z;
return float4(z, z, z, 1);
}
...which made me think that the initial pass did need a pixel shader to process the map somewhere. Although the RasterTek tutorial says to do the same thing, which leaves me in a confused state about this I guess.
So is this step not required? Am I right in trying to sample direct from the depth buffers SRV (d3dShadowMapSRV as was created in the above snippet)?