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

[TEST?] major ReShade overhaul #383

Closed
Arcitec opened this issue Dec 18, 2021 · 26 comments
Closed

[TEST?] major ReShade overhaul #383

Arcitec opened this issue Dec 18, 2021 · 26 comments

Comments

@Arcitec
Copy link
Contributor

Arcitec commented Dec 18, 2021

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:

  • Install Nier Replicant via Steam.
  • Set SteamTinkerLaunch (latest Git Master version) as my compatibility tool.
  • Launch the game and click "Main Menu" to get to the SteamTinkerLaunch GUI.
  • Click on the Game Shaders button and wait for it to download all shaders.
  • Close the Shader selection GUI without enabling any of them.
  • Go into the game's STL config and enable "enable, install, update ReShade" checkboxes.
  • Run the game.
  • Exit the game and launch it again and go back to STL's main menu.
  • Click on the "Game Shaders" button and then enable one of the shaders (BloomingHDR).
  • Run the game.

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
Copy link
Contributor Author

Arcitec commented Dec 18, 2021

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
Copy link
Contributor Author

Arcitec commented Dec 18, 2021

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
Copy link
Collaborator

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
  • stray dead symlinks when shaders were removed or the source directory was changed completely
  • it would be no longer possible to keep a specific shader version for one game
  1. This would be a yad feature, and it looks like it doesn't exist - at least I haven't found anything

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
Copy link
Collaborator

  1. Rewrite the En/Disable ReShade option (see [BUG] ReShade Enable/Disable is Broken #382)

@frostworx frostworx changed the title [BUG] ReShade shaders are improperly installed directly into the game directory [TODO] major ReShade overhaul Dec 19, 2021
@Arcitec
Copy link
Contributor Author

Arcitec commented Dec 19, 2021

@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
Copy link
Contributor Author

Arcitec commented Dec 19, 2021

Regarding symlinks:

  • "it would be no longer possible to keep a specific shader version for one game", this doesn't matter. Nobody does that. But if they do, they can manually copy it in there. :D
  • "stray dead symlinks when shaders were removed or the source directory was changed completely", this is a bit more tricky but the easiest solution would be to refactor everything so that it's no longer "enable shaders one by one" but instead "enable shader collections". Then you can just symlink a game's ./reshade-shaders/Shaders/martymcfly ---> ~/.config/steamtinkerlaunch/downloads/shaders/martymcfly/Shaders or similar.

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
Copy link
Contributor Author

Arcitec commented Dec 19, 2021

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
Copy link
Collaborator

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
Copy link
Collaborator

frostworx commented Dec 24, 2021

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
Copy link
Collaborator

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

@frostworx
Copy link
Collaborator

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
Copy link
Collaborator

@Bananaman 👍

@frostworx frostworx changed the title [TODO] major ReShade overhaul [DONE] major ReShade overhaul Jan 10, 2022
@frostworx frostworx changed the title [DONE] major ReShade overhaul [TEST?] major ReShade overhaul Jan 11, 2022
@frostworx
Copy link
Collaborator

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
Copy link
Contributor Author

Arcitec commented Jan 13, 2022

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":

  • All files above are rename to without _off.
  • ReShade.ini is created with this content:
[GENERAL]
EffectSearchPaths=.\reshade-shaders\Shaders
TextureSearchPaths=.\reshade-shaders\Textures

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

  • It first downloads all shaders. (Trying this later on a different game was instant, no need to download the shaders again for the next game, nice.)
  • The new GUI for selecting shaders is perfect, with entire collections enabled/disabled at once.
  • There is a subfolder reshade-shaders/enabled which contains files that tell you which shader collections are enabled.
  • All files in the Shaders and Textures directories are symlinks to a universal location. Awesome!

Deleting some "Game Shaders" via STL:

  • It lists the ones I had enabled previously.
  • Disabling some of them removes those symlinks from the game's shader directory. Great.

Unchecking "Reshade enable" again:

  • All files are now marked _off, d3d9.dll_off d3dcompiler_47.dll_off dxgi.dll_off ReShade.ini_off ReShade.txt_off
  • ReShade.txt_off contains:
d3d9.dll
d3dcompiler_47.dll
dxgi.dll

Unchecking "Reshade install" again:

  • All of the files remain: d3d9.dll_off d3dcompiler_47.dll_off dxgi.dll_off ReShade.ini_off ReShade.txt_off reshade-shaders (directory)
  • I guess the install isn't meant to be reversible. That's okay. Disabling is good enough.

Everything is great. I discovered 1 problem:

  • The generated Reshade.ini needs to contain one more line:
[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
Copy link
Contributor Author

Arcitec commented Jan 13, 2022

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
Copy link
Contributor Author

Arcitec commented Jan 13, 2022

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

  • reshade-shaders: This is the core set of utility-shaders, mainly used to get the core "ReShade.fxh" library and the "DisplayDepth" debugging effect which helps you ensure that depth buffer is read correctly. Lots of effects use the depth buffer, and most effects and third-party repos require "ReShade.fxh" and the other utility-headers from this repo. This is a must-have. https://github.com/crosire/reshade-shaders/tree/slim/Shaders
  • quint: This is the best shader collection of them all. The man is a genius and created highly optimized must-have shaders such as Lightroom. He was hired by NVIDIA to create their Ansel shaders. Everyone uses these. https://github.com/martymcmodding/qUINT/
  • prod80 reshade repository: Another genius, this guy has a ton of high quality effects for various special effects, color grading, etc.
  • shaders (brussell1): Mainly used for his "EyeAdaptation" shader which is able to brighten or darken a scene based on how light it is. Very useful when creating shaders that end up darkening some areas too much, then you can simply brighten just the dark rooms with this shader.
  • astrayfx: These are pretty good, especially his "RadiantGI" which is basically a freeware version of the same techniques used in the popular Patreon "raytracing" shader. It's not the exact same result, but it's good. It's the same guy that made the depth3d filters, and I've talked to him a few times on his discord. He's a nice guy.

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

@frostworx
Copy link
Collaborator

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
Copy link
Collaborator

yeah, fixing bugs during lunch break ftw :)
Both missing PreprocessorDefinitions and ReShade.ini restoration hould be fixed with feda4a4

@Arcitec
Copy link
Contributor Author

Arcitec commented Jan 14, 2022

@frostworx Heyyyy! :)

I've tested the latest updates.

  • New ReShade.ini is now created with preprocessordefinitions, and I can confirm that the ingame ReShade menu "Edit Preprocessor Definitions" button now bings up a menu with these settings as it should! :)
  • Restoring ReShade.ini_old -> ReShade.ini now works. I tried enabling/disabling many times, and it always worked.

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:

  • Final Fantasy XIV (this is the biggest GShade community)
  • Elder Scrolls Online
  • GuildWars 2
  • Phantasy Star Online 2
  • Black Desert Online
  • Second Life
  • TERA Online
  • Warframe
  • World of Warcraft

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
Copy link
Collaborator

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
Copy link
Contributor Author

Arcitec commented Jan 14, 2022

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:

martymcmodding/qUINT#28 (comment)

But for online games it's the best choice.

@Arcitec
Copy link
Contributor Author

Arcitec commented Jan 14, 2022

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

@frostworx
Copy link
Collaborator

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
Copy link
Contributor Author

Arcitec commented Jan 14, 2022

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
Copy link
Contributor Author

Arcitec commented Jan 14, 2022

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): #383 (comment)

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

@frostworx
Copy link
Collaborator

frostworx commented Jan 14, 2022

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

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

No branches or pull requests

2 participants