Uniform shader parameters

  • luluco250
  • Topic Author
More
7 years 1 month ago - 7 years 1 month ago #1 by luluco250 Uniform shader parameters was created 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));
    }
}
Last edit: 7 years 1 month ago by luluco250.

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

  • crosire
More
7 years 1 month ago #2 by crosire Replied by crosire on topic Uniform shader parameters
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.

  • luluco250
  • Topic Author
More
7 years 1 month ago #3 by luluco250 Replied by luluco250 on topic Uniform shader parameters
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.

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.