Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Coded by Prod80
- Ported to ReShade 3.x by Insomnia
- Version 1.4
- */
- #include "ReShade.fxh"
- uniform int iUsehslfilter <
- ui_type = "combo";
- ui_label = "Use HSL Filter";
- ui_items = "No\0Yes\0";
- > = 0;
- uniform float3 ccFilterLuma <
- ui_type = "color";
- ui_min = 0.0; ui_max = 1.0;
- ui_label = "Luma Coefficient";
- ui_tooltip = "Only for advanced users";
- > = float3(0.2125, 0.7154, 0.0721);
- uniform int hueMid <
- ui_type = "drag";
- ui_min = 0.0; ui_max = 360.0;
- ui_label = "Hue Mid";
- ui_tooltip = "Hue (rotation around the color wheel) of the color which you want to keep";
- > = 0;
- uniform float hueRange <
- ui_type = "drag";
- ui_min = 0.0; ui_max = 0.9;
- ui_label = "Hue Range";
- ui_tooltip = "Range of different hue's around the hueMid that will also kept";
- > = 0.2;
- uniform float satLimit <
- ui_type = "drag";
- ui_min = 0.1; ui_max = 1.0;
- ui_label = "Saturation Limit";
- ui_tooltip = "Saturation control, better keep it higher than 0 for strong colors in contrast to the gray stuff around";
- > = 1.0;
- uniform float fxcolorMix <
- ui_type = "drag";
- ui_min = 0.0; ui_max = 1.0;
- ui_label = "Color Mix";
- ui_tooltip = "Interpolation between the original and the effect, 0 means full original image, 1 means full grey-color image";
- > = 1.0;
- //#define Use_COLORSAT 0 //[0:1] //-This will use original color saturation as an added limiter to the strength of the effect
- //#define LumCoeff float3(0.212656, 0.715158, 0.072186)
- float smootherstep(float edge0, float edge1, float x)
- {
- x = clamp((x - edge0)/(edge1 - edge0), 0.0, 1.0);
- return x*x*x*(x*(x*6 - 15) + 10);
- }
- float3 Hue(in float3 RGB)
- {
- // Based on work by Sam Hocevar and Emil Persson
- float Epsilon = 1e-10;
- float4 P = (RGB.g < RGB.b) ? float4(RGB.bg, -1.0, 2.0/3.0) : float4(RGB.gb, 0.0, -1.0/3.0);
- float4 Q = (RGB.r < P.x) ? float4(P.xyw, RGB.r) : float4(RGB.r, P.yzx);
- float C = Q.x - min(Q.w, Q.y);
- float H = abs((Q.w - Q.y) / (6 * C + Epsilon) + Q.z);
- return float3(H, C, Q.x);
- }
- float3 HUEToRGB(in float H)
- {
- float R = abs(H * 6 - 3) - 1;
- float G = 2 - abs(H * 6 - 2);
- float B = 2 - abs(H * 6 - 4);
- return saturate(float3(R,G,B));
- }
- static const float Epsilon = 1e-10;
- float3 RGBToHCV(in float3 RGB)
- {
- // Based on work by Sam Hocevar and Emil Persson
- float4 P = (RGB.g < RGB.b) ? float4(RGB.bg, -1.0, 2.0/3.0) : float4(RGB.gb, 0.0, -1.0/3.0);
- float4 Q = (RGB.r < P.x) ? float4(P.xyw, RGB.r) : float4(RGB.r, P.yzx);
- float C = Q.x - min(Q.w, Q.y);
- float H = abs((Q.w - Q.y) / (6 * C + Epsilon) + Q.z);
- return float3(H, C, Q.x);
- }
- float3 RGBToHSL(in float3 RGB)
- {
- float3 HCV = RGBToHCV(RGB);
- float L = HCV.z - HCV.y * 0.5;
- float S = HCV.y / (1 - abs(L * 2 - 1) + Epsilon);
- return float3(HCV.x, S, L);
- }
- float3 HSLToRGB(in float3 HSL)
- {
- float3 RGB = HUEToRGB(HSL.x);
- float C = (1 - abs(2 * HSL.z - 1)) * HSL.y;
- return (RGB - 0.5) * C + HSL.z;
- }
- float3 HUEFXPass(float4 position : SV_Position, float2 texcoord : TexCoord) : SV_Target
- {
- float3 color = tex2D(ReShade::BackBuffer, texcoord).rgb;
- float4 r0; float2 r1; float2 r2;
- r0.xyz = saturate( color.xyz );
- r0.w=dot(r0.xyz, ccFilterLuma.xyz/dot(ccFilterLuma.xyz, 1));
- r1.x = RGBToHSL( r0.xyz ).x;
- float hueMids = hueMid * (1.0/360.0);
- r2.xy=float2(hueMids-hueRange, hueMids+hueRange);
- if(r2.y>1 && r1.x<r2.y-1)
- r1.x+=1;
- if(r2.x<0 && r1.x>r2.x+1)
- r1.x-=1;
- if(r1.x<hueMids)
- r0.xyz=lerp(r0.w, r0.xyz, smootherstep(r2.x, hueMids, r1.x)*satLimit);
- if(r1.x>=hueMids)
- r0.xyz=lerp(r0.w, r0.xyz, (1-smootherstep(hueMids, r2.y, r1.x))*satLimit);
- color.xyz=lerp(color.xyz, r0.xyz, fxcolorMix);
- if(iUsehslfilter == 1)
- {
- color.xyz=RGBToHSL(saturate(color.xyz));
- color.x=color.x+color.x-smootherstep(1, color.x+r0.x,1);
- color.y=color.y+((1-color.y)*(r0.y*color.y));
- color.z=color.z+((1-color.z)*(r0.z*color.z));
- color.z=color.z+((1-color.z)*(r0.w*(1-color.z)));
- color.xyz=HSLToRGB(saturate(color.xyz));
- }
- return color;
- }
- technique HueFX
- {
- pass
- {
- VertexShader = PostProcessVS;
- PixelShader = HUEFXPass;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement