I'm currently working on my shading in Vulkan. I've created a separate render pass for my shadow map basing on SaschaWillem's and Itoral's code. The base of my app was based on VulkanTutorial.
The problem I'm having is that the depth buffer the Z values ought to be written to is entirely filled with zeros. I'm currently passing the same MVP as for the camera to the shadow map shader. I've attached RenderDoc to my app and the Mesh Output tab for the shadow map pass contains exactly the same values for gl_Position as the regular pass. Unfortunately the values are not being saved to the buffer as the Texture Viewer shows.
Meanwhile the regular depth buffer is properly filled with the values computed in the regular shader.
"Every time the rasterizer produces a fragment, the depth test will check if the new fragment is closer than the previous one. If it isn't, then the new fragment is discarded. A fragment that passes the depth test writes its own depth to the depth buffer."
It looks as if all the fragments are being discarded.
I'm all out of ideas on how to proceed. Could you please point me in the direction where to look for the cause of this issue?
It seems that the render pass' clear values were the problem here.
std::array<VkClearValue, 1> clearValues = {};
clearValues[0].depthStencil = { 1.0f, 0 };
renderPassInfoStruct.clearValueCount = 1;
renderPassInfoStruct.pClearValues = clearValues.data();
Is what fixed the issue for me. Previously index 0 had color values set to { 0.f, 0.f, 0.f, 1.f };
Thank you Jesse for the suggestion to go through that again, otherwise I would probably never find it :)