Welcome, Guest.
Username: Password: Remember me

TOPIC: Uniform shader parameters

Uniform shader parameters 1 year 4 months ago #1

In HLSL it's possible to define uniform parameters in shaders and pass custom values upon their definition in the techniques.
Could such a thing be possible to add to ReShade FX? Example:
float4 PS_Foo(float4 pos : SV_Position, float2 uv : TEXCOORD, uniform float2 dir) {
//blur in the direction defined by dir
}

technique Bar {
    pass X {
        VertexShader = PostProcessVS;
        PixelShader = PS_Foo(float2(1.0, 0.0));
    }
    pass Y {
        VertexShader = PostProcessVS;
        PixelShader = PS_Foo(float2(0.0, 1.0));
    }
}
Likes to reinvent the wheel.

My shaders repository: www.github.com/luluco250/FXShaders
Last Edit: 1 year 4 months ago by luluco250.
The administrator has disabled public write access.

Uniform shader parameters 1 year 4 months ago #2

I thought about adding that, but it would require argument parsing in the technique block, which overcomplicates the compiler code. And since the same can be done with only a few more lines of code I decided against it:
float4 PS_Foo(float4 pos : SV_Position, float2 uv : TEXCOORD, float2 dir) {
//blur in the direction defined by dir
}

float4 PS_FooX(float4 pos : SV_Position, float2 uv : TEXCOORD) { return PS_Foo(pos, uv, float2(1.0, 0.0)); }
float4 PS_FooY(float4 pos : SV_Position, float2 uv : TEXCOORD) { return PS_Foo(pos, uv, float2(0.0, 1.0)); }

technique Bar {
    pass X {
        VertexShader = PostProcessVS;
        PixelShader = PS_FooX;
    }
    pass Y {
        VertexShader = PostProcessVS;
        PixelShader = PS_FooY;
    }
}
Cheers, crosire =)
The administrator has disabled public write access.

Uniform shader parameters 1 year 4 months ago #3

Yeah I'm aware it's essentially a non-problem, just syntactic sugar, but it'd be nice.
Oh well, if it'd overcomplicate the compiler too much then I guess it's for the better good not to have it then.
Likes to reinvent the wheel.

My shaders repository: www.github.com/luluco250/FXShaders
The administrator has disabled public write access.