protonscr

Some water in Trails through Daybreak renders incorrectly on Nvidia GPU's

dxvkclosed d3d11nvidia proprietary
doitsujin/dxvk#4162 · opened 2024-07-20 by UltraSunDK · updated 2024-08-11 · 9 comments · github
UUltraSunDK 2024-07-20 github

Running The Legend of Heroes: Trails through Daybreak with DXVK on Windows and reportedly Linux machines using Nvidia GPU's results in water rendering at Thaarbad (ingame location) to render incorrectly.

The issue shows itself by odd looking lines in the water texture that are not present normally otherwise:
Image of issue:
20240720233539_1

Here is how it's supposed to look:
20240720233717_1

I do not currently have a Nvidia powered machine running Linux on hand, but a user on the Steam forums for Trails through Daybreak reported their Linux Mint 21.3 PC with a Nvidia GeForce RTX 3070ti and Intel i9-9900kf have the issue and I on Windows using Nvidia hardware can reproduce it too using the latest version of DXVK. Forum thread in question is linked here: https://steamcommunity.com/app/2138610/discussions/0/4521134886148456576/

I have additionally been able to confirm with others that the issue is not present on the Steam Deck nor on Windows using DXVK on AMD GPU's. This therefore appears to be an exclusively Nvidia issue on both Windows and Linux when using DXVK in this game.

A save game at the location is linked here, for if you own the game to check with it: https://1drv.ms/u/s!AsdkXaek-4Dwj8x9UOQ3ngM_mAWJQg?e=URGx6G

Software information

Game: The Legend of Heroes: Trails through Daybreak
Platform: Steam
Game version: v1.3.5

I have been able to confirm the issue is present on whatever settings is used, including both Water Shading options.
The only necessity is a Nvidia GPU.

System information

Windows PC:

  • GPU: Nvidia GeForce RTX 4090
  • Driver: 560.70
  • Wine version: N/A
  • DXVK version: 2.4

Apitrace file(s)

Apitrace file:
https://1drv.ms/u/s!AsdkXaek-4Dwj8x-rVF2mNIiZEe3jQ?e=q12gyI
Note: This was generated using the quick load feature that Trails through Daybreak features.

Log files

DXVK logs from Windows
kuro_dxgi.log
kuro_d3d11.log

BBlisto91 2024-07-21 github

Thank you for a well made issue.
I can see that the fog just above the horizon doesn't render in either with dxvk. I assume that is also a bug and not a settings change?

UUltraSunDK 2024-07-21 github

Thank you for a well made issue. I can see that the fog just above the horizon doesn't render in either with dxvk. I assume that is also a bug and not a settings change?

It's not a settings change indeed and something that was noticed after submission on my end. Both screenshots should have been taken using the same settings. The fog in that background is slightly moving however, but after multiple loads it did seem consistent in its difference.

If you need any more info on that matter (including more pictures/api traces) for other settings combinations, I'll be happy to provide it.

KK0bin maintainer 2024-07-21 github

Does disabling MSAA (if possible) make a difference?

UUltraSunDK 2024-07-21 github

Does disabling MSAA (if possible) make a difference?

The game supports the following AA options natively:

  • Off
  • Basic AA - Blur filter
  • FXAA
  • MSAA - 2x to 8x
  • SGSSAA - 2x to 8x
  • Transparency Multisampling

In my testing on Windows the issue is present with every AA setting including Off.
I have also attempted to lower every setting to their absolute minimum, with no changes in the reported water issue when using DXVK.

Ddoitsujin maintainer 2024-07-22 github

Shader seems to have some fragile math involving trigonometric functions going on, which seems to be the cause of the issue but also makes things hard to debug since differences in output between different drivers are entirely expected and within spec.

TL;DR no idea what's going on, I don't see any obvious bug on our end though.

PPeterTh 2024-07-22 github

The water shader indeed relies on specific outputs in some rather insignificant bits of trigonometric functions for its perlin noise implementation. For Kuro 2, we actually had to replace this noise function because it would break in a different context (natively in D3D11) specifically on AMD hardware due to floating point inaccuracy (which is rather amusing, given that it was written for PS5 originally).

@doitsujin if you think it helps I can provide debug shaders and/or shader code for this, but I could believe that it's relying on unspecified behaviour.

Ddoitsujin maintainer 2024-08-08 github

Found the cause, it's actually dot products.

I suppose we need to emit those in a way that matches what d3d shader compilers do. I remember Mesa getting some sort of patch for that too the other day because this isn't the first game where the exact order of operations matters.

Edit: Yeah, fma chain + marking things as precise to prevent compilers from applying transformations to it fixes the issue at least on my 4070. This more or less matches what happens on RADV already, so no changes there.

UUltraSunDK 2024-08-08 github

I've retested the scene with the referenced pull request above and it appears to fix the issue on Windows.
20240808173549_1

I will however have to note one thing I forgot to mention in the initial report. There are actually two different PC versions of Trails through Daybreak from two different developers. The pull request fixes the Western/Japanese version developed by PH3 games, but the Chinese/Korean version published by Clouded Leopard Entertainment has the same issue with the water, but as they use a different name for the executable, the fix is not applied for that version.

Here is a image of the Clouded Leopard Entertainment version.
20240808173044_1

Here is Clouded Leopard Entertainment with the executable renamed from ed9.exe to kuro.exe
image

So the pull request fixes both versions of the game, but as Clouded Leopard Entertainment named the executable ed9.exe the change is not applied automatically to that version of the game.

Note: Clouded Leopard Entertainment also named the executable for the sequel ed9.exe, so whitelisting that will whitelist two games. I have not been able to verify myself if the same issue is present in the sequel however.

Ddoitsujin maintainer 2024-08-09 github

Added ed9.exe too for now. Applying this to kuro 2 won't be an issue since we're planning to make this the default behaviour anyway relatively soon.

Nothing extracted yet.