narzoul / DDrawCompat

DirectDraw and Direct3D 1-7 compatibility, performance and visual enhancements for Windows Vista, 7, 8, 10 and 11
BSD Zero Clause License
878 stars 67 forks source link

More findings on the projected headlights issue (NFS 3-5) #327

Open PlayNeth opened 3 weeks ago

PlayNeth commented 3 weeks ago

Turns out Porsche Unleashed relies on the same texture technique for the projected headlights, but here's the thing: when running the game raw, with some ACT patches the issue with the black dots/z-fighting seemingly goes away.

EmulateHeap + DXPrimaryEmulation -DisableMaxWindowedMode + SingleProcAffinity should be enough to get the raw game up and running, and the projected headlights suddenly works as intended.

I'm just really curious what exactly causes this issue, as setting the DepthBuffer to 16 in DDC or any other wrapper isn't enough to fully fix the issue. And unlike the other two games it's actually easy to reproduce thanks to ACT. Maybe we can finally put this enigma to rest.

narzoul commented 3 weeks ago

This is not enough to run the game without a wrapper for me. There are no screen sizes to select in the graphics settings, and as expected, the game crashes when trying to enter a race. Did you install some patches?

PlayNeth commented 3 weeks ago

Just Silent's patch + a custom .exe from myabandonware to fix low resolution textures issue. I'll send your way my current .sdb just in case:

Keep in mind this one looks for that custom exe's checksum porsche.zip

All else fails I'll link you to the preset package we use in RRP.

BEENNath58 commented 3 weeks ago

There are no screen sizes to select in the graphics settings

If I am not wrong, the same thing happened in NFS4 due to "too much video memory".

Other than that, you could add the 16-bit color mode, since the game enumerates them too along with the ACT shim "that hides video modes"

narzoul commented 3 weeks ago

So I guess it can't be fixed without a wrapper? I can't find a shim to limit video memory.

Anyway, DDrawCompat v0.3.2 fixes it, and it doesn't seem to have any black dots in the projected headlights. v0.4.0 does. @PlayNeth Can you confirm?

PlayNeth commented 3 weeks ago

Yep! Can confirm.

narzoul commented 3 weeks ago

I think I narrowed down the issue to this commit: https://github.com/narzoul/DDrawCompat/commit/c7143836139d0448b22929d206cb97711cd05af9 Unfortunately, it's one of the big ones, so it'll take some time to narrow it down further.

You can double check my results, since I uploaded all the builds between v0.3.2 and v0.4.0 under the v0.4.0 release. Here's a direct link: https://github.com/narzoul/DDrawCompat/releases/download/v0.4.0/DDrawCompat-v0.4.0-debug-previous-builds.7z The last good version was v0.3.2-31-g8b393ea4, and the first bad one is v0.3.2-32-gc7143836.

narzoul commented 3 weeks ago

It's broken by the VertexFixup shader. Not because of any bug (as far as I can tell), but because it unavoidably introduces some minor floating point inaccuracies to the X, Y, Z and RHW vertex coordinates supplied by the application. I don't see any way to fix it other than to disable the shader and use the built-in transformed vertex handling: ddraw.zip (diff.txt compared to v0.5.2)

The problem with this is that a number of fixes and features use the VertexFixup shader, which currently won't work without it, including the AlternatePixelCenter and ResolutionScale settings (when used with pre-transformed vertices, like in this game). In theory, they could all be implemented on the CPU side with some performance penalty. I might do it for the next release, with some new config option.