Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[d3d8] Nvidia Shadow Buffers support #4257

Open
WinterSnowfall opened this issue Sep 12, 2024 · 7 comments · May be fixed by #4660
Open

[d3d8] Nvidia Shadow Buffers support #4257

WinterSnowfall opened this issue Sep 12, 2024 · 7 comments · May be fixed by #4660
Labels

Comments

@WinterSnowfall
Copy link
Contributor

Just so we don't forget about it. Nvidia Shadow Buffers (a cutting edge GeForce 4 tech at the time, whose marketing claims remind one of modern age ray tracing) are explicitly needed in Splinter Cell: Pandora Tomorrow, but also enhance the experience in the first game of the series.

@AlpyneDreams had a d8vk branch that added support (d9vk-level changes were also involved IIRC), but it never made it as part of the d8vk merge, apart from a dxvk.conf/config.cpp remnant that got removed in #4144 . We should revisit the topic at some point for sure.

@K0bin K0bin added the d3d8 label Sep 30, 2024
@AlpyneDreams
Copy link
Contributor

The "shadow buffers" feature was actually an embellishment in the form of extra samples from dgVoodoo 2 that I assumed was hardware-accurate. I think the hardware actually did only a regular bilinear tap (but I don't have the hardware and I haven't done empirical testing - so I can't say for certain).

The "dref scaling" feature (d3d8.scaleDref) however is a config option necessary for Splinter Cell. Its shaders expect nonstandard behavior with non-normalized integer depth values. However it seems to never have been added to the config for that game and the spinoff games that shares its engine. So that definitely needs to be fixed

@AlpyneDreams
Copy link
Contributor

It appears we'll need a similar PR for Splinter Cell: Pandora Tomorrow according to this page. Can someone test and commit that? I don't own that game.

@flibitijibibo
Copy link
Contributor

If nobody else has it I can try to find the discs and test locally.

@WinterSnowfall
Copy link
Contributor Author

I think the hardware actually did only a regular bilinear tap (but I don't have the hardware and I haven't done empirical testing - so I can't say for certain).

If you have a way that can be captured (perhaps with a test?) I have a GeForce 4 Ti 4800 in my retro PC, so can shed some light here.

It appears we'll need a similar PR for Splinter Cell: Pandora Tomorrow according to this page. Can someone test and commit that? I don't own that game.

It's ever more critical for Pandora Tomorrow, as stealth detection mechanics in some sections of the game depend on shadow buffers working properly. Because there's no way to cater for that on modern hardware, the game is currently unavailable digitally (and it's the only game in the Splinter Cell series that's in this particular situation).

I have the game and can test it, but whatever worked for the first game in the series will most likely also work here, since both are using the same engine.

@WinterSnowfall
Copy link
Contributor Author

scaleDref appears to be enough for Pandora Tomorrow, however the original Splinter Cell still doesn't look age accurate (see below)

Current master

SplinterCell

GeForce 4

ActualHardware

@tobiasjakobi
Copy link
Contributor

tobiasjakobi commented Jan 31, 2025

FYI: I restored this shadow buffers branch at some point, see here -- but it didn't result in the expected results.

Still looking forward to seeing this being supported.

@AlpyneDreams
Copy link
Contributor

AlpyneDreams commented Jan 31, 2025

from my PR:

Splinter Cell seems to expect its shaders to do a perspective divide when sampling shadow maps even though it never sets D3DTTFF_PROJECTED. As far I'm aware, this game never worked properly except for on legacy D3D8 drivers for Windows XP with earlier GeForce cards, so I have to assume this was a driver hack. At some point D3D8 drivers or the frontend were updated to match the D3D9 behavior, breaking the game entirely. This document from NVIDIA says that the XYZ coordinates are divided by W (it calls them STR and Q), but never mentions D3DTTFF_PROJECTED.

Without the perspective divide, shadows are broken in some (but not all) scenes rendering the game unplayable as they need to be visible for stealth. To further complicate things, the shader also seems to expect that the second texcoord (texcoord 1) also has perspective divide applied, even though texture 1 is a non-depth light cookie texture so it's not as simple as applying perspective divide for all depth textures.

What this hack does is it will simply force perspective divide for stages 0 and 1 when a depth texture/shadow map is bound to stage 0, and ignore any pleas from the game to set the texture transform flags back to zero while the shadow map is bound.

I have not been able to find any indicators the game might provide to the driver to enable a hack somehow (e.g. a FOURCC code) and a deep dive on the web has returned nothing. I was not able to find any nonstandard texture stage states passed in, and the shaders don't seem to have any special flags or extensions used. It has been nearly impossible to fully know if the game is doing anything like that because the game crashes on my machine when using renderdoc, apitrace, and d3d8to9 on Linux, so my information is incomplete. Therefore, this hack might not necessarily perfectly emulate what those drivers are doing but it makes the game work.

If someone could get a d3d8 apitrace of the game running with shadows enabled, we might be able to work out a bit more about what's going on here. I have attached a relevant save game file that would need to be traced:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants