DadSchoorse / vkBasalt

a vulkan post processing layer for linux
zlib License
1.24k stars 52 forks source link

CRT-Royale support #223

Open Yasand123 opened 1 year ago

Yasand123 commented 1 year ago

There's a port of the well known CRT-Royale shader for Reshade. However vkBasalt doesn't seem to be able to load it correctly. Other reshades work fine like /opt/reshade/shaders/CRT.fx

CRT-Royale reshade: https://github.com/akgunter/crt-royale-reshade

Console output

john@~ $ ENABLE_VKBASALT=1 vkcube
vkBasalt info:  config file: /home/john/.config/vkBasalt/vkBasalt.conf
vkBasalt info:  effects = crt
vkBasalt info:  enableOnLaunch = True
vkBasalt info:  toggleKey = Home
vkBasalt info:  reshadeTexturePath = /opt/reshade/textures
vkBasalt info:  reshadeIncludePath = /opt/reshade/shaders
vkBasalt info:  smaa = /opt/reshade/shaders/SMAA.fx
vkBasalt info:  crt = /opt/reshade/shaders/CRT-Royale/crt-royale.fx
Selected GPU 0: NVIDIA GeForce RTX 2060 SUPER, type: DiscreteGpu
vkBasalt err:   failed to load shader file: /opt/reshade/shaders/CRT-Royale/crt-royale.fx
vkBasalt err:   Does the filepath exist and does it not include spaces?
vkBasalt err:   /opt/reshade/shaders/crt-royale/shaders/../lib/helper-functions-and-macros.fxh(29, 8): error X3004: undeclared identifier or no matching intrinsic overload for 'tex2Dlod'
vkBasalt err:   /opt/reshade/shaders/crt-royale/shaders/../lib/bind-shader-params.fxh(148, 25): error X3000: syntax error: unexpected 'identifier', expected ','
vkBasalt err:   /opt/reshade/shaders/crt-royale/shaders/../lib/bind-shader-params.fxh(148, 25): error X3000: syntax error: unexpected 'identifier'
vkBasalt err:   /opt/reshade/shaders/crt-royale/shaders/../lib/bind-shader-params.fxh(148, 28): error X3000: syntax error: unexpected 'integral literal'
vkBasalt err:   /opt/reshade/shaders/crt-royale/shaders/../lib/bind-shader-params.fxh(148, 31): error X3000: syntax error: unexpected 'identifier'
vkBasalt err:   /opt/reshade/shaders/crt-royale/shaders/../lib/bind-shader-params.fxh(148, 34): error X3000: syntax error: unexpected 'integral literal'
vkBasalt err:   /opt/reshade/shaders/crt-royale/shaders/../lib/bind-shader-params.fxh(148, 37): error X3000: syntax error: unexpected 'identifier'
vkBasalt err:   /opt/reshade/shaders/crt-royale/shaders/../lib/bind-shader-params.fxh(148, 40): error X3000: syntax error: unexpected 'integral literal'
vkBasalt err:   /opt/reshade/shaders/crt-royale/crt-royale.fx(65, 1): warning X4576: 'preblurHorizPS': input parameter 'texcoord' semantic does not match vertex shader one
vkBasalt err:   /opt/reshade/shaders/crt-royale/crt-royale.fx(111, 1): warning X4576: 'approximateBloomVertPS': input parameter 'texcoord' semantic does not match vertex shader one
vkBasalt err:   /opt/reshade/shaders/crt-royale/crt-royale.fx(119, 1): warning X4576: 'approximateBloomHorizPS': input parameter 'texcoord' semantic does not match vertex shader one
vkBasalt err:   /opt/reshade/shaders/crt-royale/crt-royale.fx(184, 1): warning X4576: 'applyComputedPhosphorMaskPS': input parameter 'texcoord' semantic does not match vertex shader one
Segmentation fault (core dumped)

Sysinfo

andersstorhaug commented 10 months ago

I've found that it's actually possible to run CRT-Royale with vkBasalt, with some edits to the shader:

With these changes, it seems that CRT-Royale works fine via vkBasalt. However, specifying an antialias value other than 0 (default) still crashes the compiler.

I suspect that updating the ReShade submodule in vkBasalt would resolve most of these issues, however, I'm not sure if that's an easy task.

andersstorhaug commented 10 months ago

On a broader note, you really have to wonder if vkBasalt couldn't use librashader to support RA shaders. I think that's been suggested here in another issue. I might end up attempting to do this myself and opening a PR, but, not sure what I'd be getting into 😅.

The thing that sparks my interest in vkBasalt, is that you can use it with gamescope and apply raster-based shaders to the entire texture that gamescope produces. That isn't currently possible with gamescope alone, even though gamescope also has limited support for ReShade shaders. And this works for any game whether or not the game itself uses Vulkan, pending at least that you have a recent build of gamescope and ideally an AMD graphics card for the time being.

andersstorhaug commented 9 months ago

As a side note.. I was able to fix antialiasing as well. In tex2Daa functions, had to fix the assignment for true_pixel_to_tex_uv by replacing float2x2 * float with mul(float, float2x2).

Output looks identical now to native ReShade, AFAICT.

Still, not sure if it's worth pushing anything upstream to CRT-Royale reshade. But if anyone wants the vkBasalt-compatible version, let me know.

Yasand123 commented 9 months ago

Still, not sure if it's worth pushing anything upstream to CRT-Royale reshade. But if anyone wants the vkBasalt-compatible version, let me know.

I read your first and second comments but I don't have experience with shaders at all. If you could share it it would be much appreciated. Others would benefit as well. 😊

andersstorhaug commented 9 months ago

I'm currently looking into building a Vulkan layer with librashader support. A bit new to Vulkan, and somewhat new to graphics pipelines themselves, outside of shaders a-la ReShade.. so we'll see how that goes. Decided to start from scratch here just to make things simpler from my side of things, but assuming all goes well if @DadSchoorse would prefer I would have no problem with pushing this upstream to eventually add librashader to vkBasalt.

But, no promises here -- this really depends on what free time I have, and also my ability :sweat_smile:.

In the meantime, I'll push a repository with a version of CRT-Royale that works on vkBasalt. This will probably be a temporary thing, I may immediately archive it, but in the meantime if it's helpful to others, I don't see why not.

andersstorhaug commented 9 months ago

Here's the link to my fork of crt-royale-reshade, branch vkbasalt.

Yasand123 commented 9 months ago

Here's the link to my fork of crt-royale-reshade, branch vkbasalt.

This is very cool. Thank you for sharing! I just tried it with emulators and it works really well.

pseregiet commented 8 months ago

Here's the link to my fork of crt-royale-reshade, branch vkbasalt.

Can confirm this is working, awesome.

linkert commented 1 month ago

I'm trying this out but I'm having quite "heavy handed" results — be it when applied to the XMB retroarch menu or vkcube or Blasphemous II.

image

I know the regular ReShade version allows for configuration. The vkBasalt github page links to a merged pull request that supposedly allows for "some" configuration of reshade shaders but I'm not grasping how to format this and if it applies to the vkBasalt-adapted version by @andersstorhaug?

Anyone care to enlighten me on possible configuration to improve the situation?