sonic2kk / steamtinkerlaunch

Linux wrapper tool for use with the Steam client for custom launch options and 3rd party programs
GNU General Public License v3.0
2.14k stars 72 forks source link

[TEST?] major ReShade overhaul #383

Closed Arcitec closed 2 years ago

Arcitec commented 2 years ago

I was reading the Reddit discussion and saw someone mentioning that SteamTinkerLaunch installs shaders directly into the game folder:

https://www.reddit.com/r/linux_gaming/comments/qyiuhv/reshadelinux_easy_setup_updating_of_reshade_on/hlhlp8l/?utm_source=reddit&utm_medium=web2x&context=3

I've now seen that issue for myself.

Here's what I did:

This is what's in my game folder (I have deleted a bunch of filenames from this list just to illustrate the point):

 BloomingHDR.fx         'NieR Replicant ver.1.22474487139.exe'
Arcitec commented 2 years ago

My step by step above is from memory. I might have enabled the shader while ReShade itself was disabled in SteamTinkerLaunch's per-game settings.

I have a theory... it could be related to this bug #382.

Perhaps if ReShade is improperly/half-disabled, and you run the game so that a default ReShade.ini is created, perhaps this then confuses SteamTinkerLaunch to think that there is no proper shader directory. I dunno... If you're reading the ReShade.ini to determine where to put shaders, then this is the likely culprit.

Arcitec commented 2 years ago

Oh and this bug also causes a total loss of shader paths. Shaders are supposed to be installed in project paths, such as:

cobrafx/Shaders/Cobra_Mask.fx

If the paths (visible in SteamTinkerLaunch's "Game Shaders" GUI) aren't preserved, then the shaders may not be able to find their own related files, or different shader sets with identical filenames may clobber each other's files, and shader presets (ReShade ini files) from the internet (i.e. NexusMods) may not find the presets.

I have 5 concerns/bugs with the "Game Shaders" GUI in SteamTinkerLaunch:

  1. It needs to install the shaders in a proper shader subdirectory, with proper paths for each shader. Otherwise different shader packs may clobber each other's files.
  2. It needs to install the related files for all shaders. This means things like textures and general function libraries that some shaders import (some authors like to put generic functions in a library that they then import into their .fx shader file). Here's an example of how many textures some shaders require: https://github.com/Mortalitas/GShade/releases
  3. It needs to support installing shaders without ReShade (for people who only use vkBasalt). Meaning that it cannot depend on ReShade.ini's existence/paths.
  4. It copies shader files. Why not symlink them to the core ReShade Shader Repos folder to ensure that they get updates/fixes? ~/.config/steamtinkerlaunch/downloads/shaders.
  5. It's difficult to enable all shaders one by one by ticking all checkboxes. Any chance of a "Enable all/Disable all" feature?

I could be wrong about a lot of these concerns, by the way! :)

frostworx commented 2 years ago

Thanks for the huge bug report.

In fact, I already wanted to refactor some ReShade code parts before, but I do not have very much time for steamtinkerlaunch anymore. I'll take your issue as an opportunity to set it as an official future goal :) Every helping hand is welcome, of course!

Looks like you know pretty much about the ReShade structure (personally I like it, but barely use it, which probably explains why I did not even recognize those issues).

1) Would be nice if you could paste a "perfect" mockup directory structure of a game directory with >2 shaders installed. (see below) 2) digging through every fx automatically and searching for includes and textures is not too much fun, that's why I simply copied all textures found in the source directories. I hope this can be automated with 1) without too much effort 3) I guess this would be auto-fixed when all ReShade stuff would be in its own subdirectory (1) 4) IIRC this either was suggested before or I considered it once. I can't remember why I decided otherwise, so it makes sense to change that with the ReShade overhaul. Possible negative side effects would be

If I didn't misunderstand anything, 1-3 are programmatically more or less one point, 4 is clear and 5 needs to be implemented in yad.

PS: Looks like it didn't read the reddit comment completely btw: The game directory is not always the absolute path to the game exe directory, so shaders dropped directly into the game directory sometimes were misplaced. That's what I meant with what I fixed. A bug report would have clarified this (as it did now :))

PPS: I'll rename this issue to show that this is a generic ReShade overhaul issue. Maybe more help/ideas are contributed

frostworx commented 2 years ago

6) Rewrite the En/Disable ReShade option (see #382)

Arcitec commented 2 years ago

@frostworx Hey, thanks a lot for the detailed answer. :)

Regarding the ultimate ReShade structure, it would be optimal to use the structure that ReShade uses by default on Windows. When a Windows users tells ReShade to install itself into a game folder, it creates this structure:

d3d9.dll (for dx9)
dxgi.dll (for dx10 and higher)
ReShade.ini (the core configuration for the runtime; this isn't a preset, it's the global config)
reshade-shaders (directory)
    Shaders (directory)
        (1 subfolder per shader collection here, with their .fx files, and each shader collection also has its related .fxh files (headers/shared code) in these folders)
    Textures (directory)
        (every texture file dumped into the same folder here, no subfolders, and ReShade doesn't support distinguishing between clashing texture filenames anyway so let things overwrite each other if clashing)

The ReShade.ini that's placed in the game folder needs to contain the default Windows reshade installer contents for it to work. But the most critical lines are the following:

[GENERAL]
EffectSearchPaths=.\reshade-shaders\Shaders
TextureSearchPaths=.\reshade-shaders\Textures

All other configs/lines will auto-create themselves. The core requirement is these two, which are required for ReShade to detect shaders/textures in its own default paths. Although I haven't tested if ReShade is smart enough to try these paths by default if no path is provided. Maybe. But probably not. We probably need a small template .ini file to install into the game folders, with these lines.

Arcitec commented 2 years ago

Regarding symlinks:

Enabling/disabling entire collections kinda makes sense, because it's not unusual for shaders within a collection to require each other or belong together. It also helps with the user interface experience of quickly and easily enabling shaders in SteamTinkerLaunch.

ReShade users are used to having hundreds of shaders installed and only using like 4-12 of them, so that shouldn't be a design concern. A typical Windows user will install shader packs (even things like GShade) and end up with shader folder sizes such as this one: https://github.com/Mortalitas/GShade/tree/master/Shaders

Arcitec commented 2 years ago

To sum up the proposed ideas:

  1. Always disable/enable all ReShade DLL files.
  2. Create a default ReShade.ini and folder structure the same way Windows ReShade installer does it.
  3. Symlink entire shader collection folders all at once, for easier GUI enabling and to ensure global, automatic updates.
  4. For textures, symlink the Textures folder to something like ~/.config/steamtinkerlaunch/downloads/textures where you've merged all texture files from all installed shader packs (and overwritten clashes). You don't need to worry about which shader packs the user has enabled. The textures folder can and should simply be the combination of all textures of all globally downloaded packs.

I'm unfortunately unable to help with the actual code, I don't know anything about the codebase and am dealing with a huge backlog of things to do already. All I can do is help with the analysis of the problems. :/

frostworx commented 2 years ago

Hey @Bananaman Thanks for the comprehensive answers ;) Looks like my current implementation is already pretty much complete and the only thing missing is indeed the migration of the shaders into a reshade-shaders subdirectory, with each shader into its own subdirectory.

Hmm, simply enabling whole shader repositories indeed is an interesting idea. It is both easier to maintain and to use. And shaders which are supposed to be running need to be activated from ReShade anyway.

Having an idea is one thing, finding the time and motivation to (re-)implement it is another. Unlikely this will happen any time soon. I'll leave this open for a while, so people have the option to discuss what is better.

frostworx commented 2 years ago

hm, doesn't look like creating an individual shader subdirectory per shader is default, so I guess I'll go this road instead:

# tree gamedir/
gamedir/
├── ReShade.ini
├── ReShadePreset.ini
├── d3dcompiler_47.dll
├── game.exe
└── reshade-shaders
    ├── Shaders
    │   ├── HexLensFlare.fx
    │   ├── KeyCodes.fxh
    │   ├── LiquidLens.fx
    │   ├── Overwatch.fxh
    │   ├── SuperDepth3D.fx
    │   └── SuperDepth3D_VR+.fx
    └── Textures
        ├── DigitMap.png
        ├── Overlay.png
        └── Pong.png

nice, subdirectories in EffectSearchPaths are entirely ignored, so creating symlinks of the whole reponame/Shaders dir into reshade-shaders/Shaders/reponame does not even work. so back to above plan a with symlinking every single shader file...

edit: not too busy because of RL, but proceeding quite nicely. Commit might make it into 2021 :)

frostworx commented 2 years ago

This giant commit should cover pretty much everything discussed (and more) :)

frostworx commented 2 years ago

Should be more or less functional with above commit. Possible that not all functions do work 100% correctly yet, but I assume this state will make it more or less into next and foreseeable last release.

frostworx commented 2 years ago

@Bananaman 👍

frostworx commented 2 years ago

When nobody is willing to give any feedback on the rewrite, I silently assume it is either fully functional or nobody uses it at all. Either way I'm going to make a new release soon.

Arcitec commented 2 years ago

Enable "ReShade install":

The DLLs are installed with d3d9.dll_off d3dcompiler_47.dll_off dxgi.dll_off ReShade.txt_off.

ReShade.txt_off contains:

d3d9.dll
d3dcompiler_47.dll
dxgi.dll

There is no reshade.ini and no shader folder.

So it properly installed itself in a disabled state.

Enable "ReShade install" and "ReShade enable":

[GENERAL]
EffectSearchPaths=.\reshade-shaders\Shaders
TextureSearchPaths=.\reshade-shaders\Textures

Clicking "Game Shaders" in the main menu of STL:

Deleting some "Game Shaders" via STL:

Unchecking "Reshade enable" again:

d3d9.dll
d3dcompiler_47.dll
dxgi.dll

Unchecking "Reshade install" again:

Everything is great. I discovered 1 problem:

[GENERAL]
EffectSearchPaths=.\reshade-shaders\Shaders
TextureSearchPaths=.\reshade-shaders\Textures
PreprocessorDefinitions=RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=1000.0,RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=0,RESHADE_DEPTH_INPUT_IS_REVERSED=1,RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=0

The preprocessor definitions is necessary and is included in the official reshade installer. It fills out the game menu with configurable preprocessor variables which must be tweaked in most gamest (usually the "reversed" value is wrong, sometimes it's upside down, etc).

If this line isn't included, then the game's "Edit Preprocessor Definitions" button brings up an empty menu.

You can see that the values I picked above are ReShade's defaults:

https://github.com/crosire/reshade/blob/16114e59ae0e521df08ff28c16dceb465a4386ac/setup/MainWindow.xaml.cs#L796-L800

Just add that to the reshade.ini that STL generates and things will be perfect :)

Arcitec commented 2 years ago

Wait, I found a bug.

If you disable shaders, ReShade.ini -> ReShade.ini_off.

If you enable shader, a new ReShade.ini is created, the _off variant is not restored. Both files exist simultaneously, but the user gets blank new config.

Arcitec commented 2 years ago

By the way, the most "essential" shader collections are:

Maybe some of this info belongs in wiki to guide the newbies, I dunno.

frostworx commented 2 years ago

Wow, thanks again for another awesome test! Will start RL work soon, and will read it carefully over the weekend. Would you mind me adding parts of your tests to the corresponding wikis? Might help people to understand what the functions do :) And do you think it makes sense to add your Smashface-Shaders to the repocustomlist.txt?

frostworx commented 2 years ago

yeah, fixing bugs during lunch break ftw :) Both missing PreprocessorDefinitions and ReShade.ini restoration hould be fixed with https://github.com/frostworx/steamtinkerlaunch/commit/feda4a40f915a1d1c89daff1223f5f0f3213986e

Arcitec commented 2 years ago

@frostworx Heyyyy! :)

I've tested the latest updates.

Perfect. STL now has excellent support for ReShade! Thank you very much! :D

Would you mind me adding parts of your tests to the corresponding wikis?

You've welcome to add/edit anything I've written if you want to add something to the wiki! :)

And do you think it makes sense to add your Smashface-Shaders to the repocustomlist.txt?

That would have been an honor, but it's not appropriate because they're made for GShade which is like ReShade but pre-bundled with tons of effects, and modified versions of other effects. So the presets aren't compatible with regular ReShade.

For 99% of games, ReShade is good enough. GShade is just used for some fans of about a dozen different online games, since regular ReShade disables itself whenever a game uses any network traffic. Don't worry about it. If someone wants GShade, there are ways to install it manually into games on Linux with their Linux installer script, and since it only matters for a few games, there's zero reason to bring GShade into STL. Besides, GShade isn't perfect, it's bloated and has a bunch of old, semi-broken shaders, so most people would prefer pure ReShade instead. :)

Here's the full list of "main games" that people use GShade for:

Here are the full games supported (it uses a whitelist to only unlock online reshade features in certain games):

https://gposers.com/gshade/gshade-faq/#1563200583477-ab0ffc4e-3d4f

https://gposers.com/gshade/gshade-faq/#1566559486490-57a55be5-e2a6

I just figured I'd describe it so that you don't have to wonder what GShade is... :P

frostworx commented 2 years ago

Hey @Bananaman Thanks for the finishing test, for your ok for the wiki and the comprehensive GShade description :) Didn't know it is not 100% to ReShade, so this indeed doesn't make much sense. Indeed I heard of GShade already before (and also its Linux installer script - iirc I even had a short discussion with the dev once on reddit :)))

Arcitec commented 2 years ago

Ahh, yeah. Pascal "Marty McFly" Gilcher, the creator of the famous raytracing shader, is no fan of GShade since they have so much outdated garbage in the effect list:

https://github.com/martymcmodding/qUINT/issues/28#issuecomment-1000360008

But for online games it's the best choice.

Arcitec commented 2 years ago

Anyway congrats on great new updates for STL! :) Thanks for everything.

frostworx commented 2 years ago

Thanks again for your excellent testing! I just updated wikis for

And already bumped the Changelog, because the new version will (likely) be ready this weekend

Closing here :) Have fun!

Arcitec commented 2 years ago

Hehe nice I just read through the wikis. Congrats on the new version. The project is in a great state now and you can take a long and well-deserved break! :) Take care!

Arcitec commented 2 years ago

While reading the wiki, I realized something. reshade-shaders contains the header files that are used by most other shaders. I've updated the note regarding that one here (so it needs a wiki update too): https://github.com/frostworx/steamtinkerlaunch/issues/383#issuecomment-1012466312

Basically, that repo is required by most other shader repos. ^^

frostworx commented 2 years ago

Thanks, in fact the reshade-shaders repo is automatically enabled when at least one other repo is selected already. (see here)