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

CRT-Royale support #223

Open
Yasand123 opened this issue Sep 10, 2023 · 8 comments
Open

CRT-Royale support #223

Yasand123 opened this issue Sep 10, 2023 · 8 comments

Comments

@Yasand123
Copy link

Yasand123 commented Sep 10, 2023

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

  • Linux arch 6.5.2-arch1-1
  • NVIDIA 2060 Super
  • AUR package vkbasalt
@andersstorhaug
Copy link

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

  • vkBasalt doesn't have float4x3, but you can replace with float4x4 and swizzle to get the same result
  • vkBasalt uses tex2Dlodoffset instead of tex2Dlod when the offset parameter is supplied
  • CRT-Royale has some uniform options that don't have a default value for help text, supply a default of 0 for these
  • CRT-Royale uses a complex set of macros to generate a version string uniform option, remove this and don't include the version .fxh

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

andersstorhaug commented Jan 5, 2024

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

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

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

andersstorhaug commented Jan 13, 2024

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 😅.

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

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

@Yasand123
Copy link
Author

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

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

Can confirm this is working, awesome.

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

3 participants