doitsujin / dxvk

Vulkan-based implementation of D3D9, D3D10 and D3D11 for Linux / Wine
zlib License
12.25k stars 784 forks source link

d3d11: LEGO Worlds shadow flickering #3714

Open Blisto91 opened 7 months ago

Blisto91 commented 7 months ago

In Lego Worlds d3d11 sometimes the ground can flicker depending on camera angle looking like a flickering shadow. See https://github.com/ValveSoftware/Proton/issues/1345#issuecomment-1805369641 for video example

Issue does not show with wined3d

Software information

LEGO Worlds d3d11 Shadow quality at Medium or High

System information

Apitrace file(s)

https://drive.proton.me/urls/CG6P7J55XC#BiYjYbfZYmgw

Log files

LEGO_Worlds_DX11.EXE_dxgi.log LEGO_Worlds_DX11.EXE_d3d11.log

doitsujin commented 7 months ago

Debugged this for a bit, this appears to be an inaccuracy with hardware Z interpolation with huge (and I'm talking insanely huge) polygons.

The game renders a box with post-projection coordinates in the range of 1e8...1e9, i.e. literally hundreds of millions of times larger than the viewport, with the w coordinate being 1.0 so there is no perspective correction or scaling at all. Sometimes, these triangles actually intersect the viewport at a relevant depth range, but the interpolated depth value that AMD hardware uses to perform the depth test is all over the place. This works fine as-is on Nvidia.

TL;DR no idea how to work around this. Exporting gl_FragDepth = position.z from the fragment shader technically works in this specific case, but doing that is just straight-up not a viable fix.