phr00t / FocusEngine

Focus Game Engine. This is Stride/Xenko fast-tracked for Phr00t's Software games. Improvements over the original Focus on Vulkan support, PC platforms, VR, performance & ease. Cherry-picks commits from other forks as needed.
MIT License
97 stars 11 forks source link

No Point Light Shadows in Vulkan #43

Closed phr00t closed 2 years ago

phr00t commented 5 years ago

Shadows seem to work for Directional & Spotlights in Vulkan -- but not Point Lights. In the editor, which is using the DirectX 11 API, I see shadows. When running the project in Vulkan, no shadows appear.

phr00t commented 5 years ago

Stepping through a test scene with a point light & shadows enabled, it looks like all 6 views are "rendered"...

It goes here: https://github.com/phr00t/xenko/blob/master/sources/engine/Xenko.Rendering/Rendering/MeshRenderFeature.cs#L142

... and when it gets to the ShadowCasterRenderFeature element, it goes to an empty Draw function... which seems suspicious. However, looks like DirectX 11 has the same behavior.

Stuff then seems to get passed to the Vulkan Command List, where DirectX 11 & Vulkan will definitely branch... meaning the problem probably lies somewhere in https://github.com/phr00t/xenko/blob/master/sources/engine/Xenko.Graphics/Vulkan/CommandList.Vulkan.cs

phr00t commented 2 years ago

Fixed with https://github.com/phr00t/FocusEngine/commit/a3d6934a2d5f83319573590bface3bc17bd406ef

Basically, there are a bunch of extra shadow stages for cubemaps and parabolas... removing these and just pointing to the 1 "shadowmapcaster" stage (which spotlight and directional light shadows already are) fixes the problem. I like the simplification of fewer stages that just seem to introduce bugs, so this fix is good enough for me! Existing projects will need to fix their own shadow stages to fix this problem.