Root cause of broken shadows: depth buffer stores non-linear NDC depth, not linear distance. closestDepth * 60.0 was wrong conversion. Fix: switch from depth-only to R32_SFLOAT color attachment approach: - Shadow vertex shader outputs world position to fragment - Shadow fragment shader writes length(fragPos - lightPos) / farPlane - Main fragment shader samples cubemap, multiplies by FAR_PLANE=60 - Separate color cube (R32_SFLOAT, sampled) + depth cube (D32_SFLOAT, depth test) - Shadow pipeline: 1 color attachment (R) + depth attachment - Color clear = 1.0 (max distance), depth clear = 1.0 Tests: 227 total, all pass - ShadowMapFaceDirectionTests: 6 face directions, 90° FOV, up vectors, valid matrices, far plane consistency - ShadowShaderTests: all 6 SPIR-V shaders exist
1.1 KiB
1.1 KiB