Uniform shader parameters

  • Posts: 177
3 years 3 months ago - 3 years 3 months ago #1 by luluco250
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));
    }
}

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

  • Posts: 3740
3 years 3 months ago #2 by crosire
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;
    }
}

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

  • Posts: 177
3 years 3 months ago #3 by luluco250
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.

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