Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ReShadeUI.fxh"
- uniform int Gamma_type < __UNIFORM_COMBO_INT1
- ui_items = "Grey gamma\0Regular Gamma\0";
- > = 0;
- uniform float Gamma < __UNIFORM_DRAG_FLOAT1
- ui_min = -1.0; ui_max = 10.0;
- > = 1.0;
- uniform bool Split <> = false;
- uniform bool Flip_split <> = false;
- uniform float Split_position < __UNIFORM_SLIDER_FLOAT1
- ui_min = 0; ui_max =1;
- ui_tooltip = "0 is on the far left, 1 on the far right.";
- > = 0.5;
- #include "ReShade.fxh"
- float3 GammaPass(float4 position : SV_Position, float2 texcoord : TEXCOORD0) : SV_Target
- {
- float3 colorOrig = tex2D(ReShade::BackBuffer, texcoord).rgb; //take only rgb component as we don't need alpha, see GammaPass writing to RGB only
- float3 color=colorOrig; //we can ditch all .rgb suffixes
- //consider using dot(color.rgb, 0.333) - which is color.r * 0.333 + color.b * 0.333 + color.g * 0.333
- float fakeluma = max(color.r, max(color.g, color.b));
- //ternary operator (condition ? iftrue : iffalse) compiles into a cmp and doesn't branch
- color = Gamma_type ? saturate(pow(fakeluma, Gamma) * color / fakeluma) : pow(color, Gamma);
- [branch] //force compiler to branch
- if(Split)
- {
- // | uv.x - split | > one pixel means line will be 2 pixels wide
- float divLine = abs(texcoord.x - Split_position) < BUFFER_RCP_WIDTH;
- float side = position.x > Split_position * BUFFER_WIDTH; //boolean split, left side is 0, right side is 1
- side = Flip_split ? 1 - side : side; //0 | 1 ---> 1 | 0
- color = lerp(color, colorOrig, side); //lerp(a,b,k) == b*k + a*(1-k), means if k is 0, take a, if k is 1, take b
- color *= 1.0 - divLine; //invert divline
- }
- return color;
- }
- technique Grey_Gamma
- {
- pass
- {
- VertexShader = PostProcessVS;
- PixelShader = GammaPass;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement