Fixing shaders for 4.0

  • Posts: 292
1 year 5 months ago #1 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.

  • Posts: 154
1 year 5 months ago - 1 year 5 months ago #2 by seri14
replace TEXHEIGHT to 240.

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

  • Posts: 292
1 year 5 months ago #3 by matsilagi
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.

  • Posts: 3741
1 year 5 months ago - 1 year 5 months ago #4 by crosire
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).
The following user(s) said Thank You: BeTa

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

  • Posts: 1221
1 year 5 months ago #5 by Marty McFly
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.

  • Posts: 3
9 months 3 weeks ago #6 by Mynameislol
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.

  • Posts: 5
3 months 1 day ago #7 by Bapho

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