Fixing shaders for 4.0

  • matsilagi
  • Topic Author
More
5 years 2 months ago #1 by matsilagi Fixing shaders for 4.0 was created by matsilagi
Hi.
I have some old shaders which are giving me errors, despite themn working fine on pre-4.0 ReShade
The error most of them gives me is: "value must be a literal scalar expression"

As an example, here is the troubling line on one of the shaders:
texture2D _TapeTex { Width = TEXWIDTH; Height = TEXHEIGHT; Format = RGBA8; };

Those values are defined as following:
#define TEXHEIGHT   int(min(noiseLinesRes, screenLinesRes))
#define TEXWIDTH 	int(((float)TEXHEIGHT*(float)BUFFER_WIDTH/(float)BUFFER_HEIGHT))

How do i fix that? Its the error that old shaders are most giving to me, and i need the code / values to be done on that specific way for it to work correctly.

I'll post again if there are more errors and after i get help with those.
Full code is available on one of my githubs (The Unity one), im pretty sure its an easy fix, but i have no idea on how to fix it.

Please Log in or Create an account to join the conversation.

  • seri14
More
5 years 2 months ago - 5 years 2 months ago #2 by seri14 Replied by seri14 on topic Fixing shaders for 4.0
replace TEXHEIGHT to 240.
Last edit: 5 years 2 months ago by seri14.

Please Log in or Create an account to join the conversation.

  • matsilagi
  • Topic Author
More
5 years 2 months ago #3 by matsilagi Replied by matsilagi on topic Fixing shaders for 4.0
I tried but it only made stuff worse, it now gives lots of different errors.



It worked fine on ReShade 3.X, but on 4.X, the new compiler doesn't like those too much.

Please Log in or Create an account to join the conversation.

  • crosire
More
5 years 2 months ago - 5 years 2 months ago #4 by crosire Replied by crosire on topic Fixing shaders for 4.0
The new compiler does not accept intrinsic functions inside literal expressions. This was an active design decision to simplify code. You are using the "min" function, which is not allowed in this context. Only basic operations like "+ - * /" and casting is allowed to compute constant values (and the "Width", "Height" etc. properties expect constant values).
Last edit: 5 years 2 months ago by crosire.
The following user(s) said Thank You: BeTa

Please Log in or Create an account to join the conversation.

  • Marty McFly
More
5 years 2 months ago #5 by Marty McFly Replied by Marty McFly on topic Fixing shaders for 4.0
I solved it for him already, did the min with bitwise.
The following user(s) said Thank You: BeTa

Please Log in or Create an account to join the conversation.

  • Mynameislol
More
4 years 6 months ago #6 by Mynameislol Replied by Mynameislol on topic Fixing shaders for 4.0
Could you share the fixed result? I am trying to fix the same VHSPRO fx for 4.3

Please Log in or Create an account to join the conversation.

  • Bapho
More
4 years 6 days ago #7 by Bapho Replied by Bapho on topic Fixing shaders for 4.0

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.