Welcome, Guest.
Username: Password: Remember me

TOPIC: Fixing shaders for 4.0

Fixing shaders for 4.0 7 months 3 weeks ago #1

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.
The administrator has disabled public write access.

Fixing shaders for 4.0 7 months 3 weeks ago #2

replace TEXHEIGHT to 240.
Last Edit: 7 months 3 weeks ago by seri14.
The administrator has disabled public write access.

Fixing shaders for 4.0 7 months 3 weeks ago #3

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.
The administrator has disabled public write access.

Fixing shaders for 4.0 7 months 3 weeks ago #4

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).
Cheers, crosire =)
Last Edit: 7 months 3 weeks ago by crosire.
The administrator has disabled public write access.
The following user(s) said Thank You: BeTa

Fixing shaders for 4.0 7 months 3 weeks ago #5

I solved it for him already, did the min with bitwise.
The administrator has disabled public write access.
The following user(s) said Thank You: BeTa