Shaders by Ioxa for ReShade 3.0
- conan2k
Ioxa wrote:
conan2k wrote: Hi Ioxa,
Tested the new "RGB mode" option. It indeed seems to bring out extra color detail but also introduces artifacts for some of blend modes (clipping issues?). Here is the screenshot for "Multiply" blend mode from Diablo III:
I couldn't reproduce what youre seeing but I wouldn't be surprised by multiply causing issues. The blend mode is 2*(original image)*(the clarity mask) and any pixels that get pushed above 1 get clamped at 1, so bright areas can get weird. You can try using the blend if mask to mask bright areas from the effect or try using the overlay blend mode (which uses multiply for pixels below 0.5 and something else for pixels above 0.5).
But if you can post your settings I'd like to try and reproduce the problem and see if I can come up with some kind of solution.
Oh, you are right. It only reproduces when the Clarity is set to process the full color range (not just mid-tones). Below are the settings that I've used:
[Clarity2.fx]
ClarityRadius=2.000000
ClarityBlendMode=3.000000
BlendIfRange=0.200000
ClarityOffset=1.250000
ClarityDarkIntensity=0.500000
ClarityBlendIfDark=0.000000
ClarityBlendIfLight=255.000000
ClarityStrength=0.450000
MaskContrast=0.320000
ClarityLightIntensity=0.000000
DitherStrength=1.000000
DebugMode=0.000000
PreprocessorDefinitions=0.000000
BTW, thanks a lot for all the work you're putting into these great shaders. Clarity is one of my favorites.
On a side note, I'd like to try porting the Clarity to MPC-HC/BE since movies will significantly benefit from this effect (and no, running Reshade over MPC is not a good solution because it can only run at the end of processing pipeline). So, any hints would be welcome. In particular, I'm not currently sure whether it's possible to port the Clarity as a single shader (instead of splitting it into four separate shaders for different passes).
Please Log in or Create an account to join the conversation.
- Marty
Ioxa wrote: There are a lot of places that something could go wrong with this.....
Thanks for elaborate explanation Ioxa. I did everything correctly. Except that I'm using bigger LUT. That is 64x40 (40 tiles by the size of 64x64). That is the only thing that I've done different...
Please Log in or Create an account to join the conversation.
- Myashi
I'm going to try it, in Hellblade
Please Log in or Create an account to join the conversation.
- Ioxa
- Topic Author
conan2k wrote:
Ioxa wrote:
conan2k wrote: Hi Ioxa,
Tested the new "RGB mode" option. It indeed seems to bring out extra color detail but also introduces artifacts for some of blend modes (clipping issues?). Here is the screenshot for "Multiply" blend mode from Diablo III:
I couldn't reproduce what youre seeing but I wouldn't be surprised by multiply causing issues. The blend mode is 2*(original image)*(the clarity mask) and any pixels that get pushed above 1 get clamped at 1, so bright areas can get weird. You can try using the blend if mask to mask bright areas from the effect or try using the overlay blend mode (which uses multiply for pixels below 0.5 and something else for pixels above 0.5).
But if you can post your settings I'd like to try and reproduce the problem and see if I can come up with some kind of solution.
Oh, you are right. It only reproduces when the Clarity is set to process the full color range (not just mid-tones). Below are the settings that I've used:
Warning: Spoiler![Clarity2.fx] ClarityRadius=2.000000 ClarityBlendMode=3.000000 BlendIfRange=0.200000 ClarityOffset=1.250000 ClarityDarkIntensity=0.500000 ClarityBlendIfDark=0.000000 ClarityBlendIfLight=255.000000 ClarityStrength=0.450000 MaskContrast=0.320000 ClarityLightIntensity=0.000000 DitherStrength=1.000000 DebugMode=0.000000 PreprocessorDefinitions=0.000000
BTW, thanks a lot for all the work you're putting into these great shaders. Clarity is one of my favorites.
On a side note, I'd like to try porting the Clarity to MPC-HC/BE since movies will significantly benefit from this effect (and no, running Reshade over MPC is not a good solution because it can only run at the end of processing pipeline). So, any hints would be welcome. In particular, I'm not currently sure whether it's possible to port the Clarity as a single shader (instead of splitting it into four separate shaders for different passes).
I'll try those settings and see if I can come up with a solution but just using the mask for bright areas is probably the best fix.
You could do it in one pass but the performance cost would be huge if you are using a large blur radius. You can take a look at the high pass sharpening shader, its basically a single pass version of clarity with much smaller blur radii. If you do want to use a large blur radius then multiple passes is the way to go. I don't know how shaders work for MPC but if the backbuffer has an 8bit alpha channel then you could probably use that to pass a luma channel from one shader to the next so you can do multiple blur passes on it.
Marty wrote:
Ioxa wrote: There are a lot of places that something could go wrong with this.....
Thanks for elaborate explanation Ioxa. I did everything correctly. Except that I'm using bigger LUT. That is 64x40 (40 tiles by the size of 64x64). That is the only thing that I've done different...
If that is the only thing you've done differently then there is a good chance that is the cause of the problem. Did you change the default settings in LUT.fx to use the larger LUT?
Change
#define fLUT_TileSizeXY 32
#define fLUT_TileAmount 32
to
#define fLUT_TileSizeXY 64
#define fLUT_TileAmount 40
If that still doesn't solve your problem then I would recommend using the default LUT to start, one less factor to worry about until you can actually get it working.
Hope it helps you out! Let me know if you have any problems with it.Myashi wrote: Man your CreateLut shader is freakin' cool
I'm going to try it, in Hellblade
Please Log in or Create an account to join the conversation.
- Echo
Ioxa wrote:
Echo wrote: After more testing I encountered the following problem with Clarity2:
Clarity1:
Both have the exact same settings/technique positions:
Warning: Spoiler![Clarity.fx]
ClarityRadius=2.000000
ClarityBlendMode=0.000000
ClarityOffset=10.000000
ClarityDarkIntensity=1.750000
ClarityBlendIfDark=0.000000
ClarityBlendIfLight=255.000000
ClarityViewMask=0.000000
ClarityViewBlendIfMask=0.000000
ClarityStrength=0.500000
ClarityLightIntensity=1.500000
BlendIfRange=0.000000
MaskContrast=0.150000
DitherStrength=0.000000
DebugMode=0.000000
Turning ClarityPerformanceMode=0/1 and MaskContrast 0/1 doesn't make a difference.
This happens the moment that I enter (really) dark areas.
Sadly it's partially fixed:
@ ClarityRGBMode=0 the problem still occurs in games like MEA & DX-MD, but the colors are intact.
@ ClarityRGBMode=1 the problem disappears, but it changes the saturation, which introduces another problem:
some colors are more saturated or less saturated then others + I use multiple shader for saturation & vibrance and for the last hour I've been trying to adjust my color shaders to retain or get close to my colors with ClarityRGBMode disabled @ 0 while ClarityRGBMode is activated @ 1 with no success.
My question/request: is it possible that you might add an option to enable/disable the saturation in ClarityRGBMode=1?
Thank you for your time reading my feedback.
Please Log in or Create an account to join the conversation.
- Ioxa
- Topic Author
Echo wrote: Thank you for updating some my favorite shaders. I finally got some time to try your updated Clarity2 in the hope that you might have fixed my issue below:
Warning: Spoiler!Ioxa wrote:
Echo wrote: After more testing I encountered the following problem with Clarity2:
Clarity1:
Both have the exact same settings/technique positions:
Warning: Spoiler![Clarity.fx]
ClarityRadius=2.000000
ClarityBlendMode=0.000000
ClarityOffset=10.000000
ClarityDarkIntensity=1.750000
ClarityBlendIfDark=0.000000
ClarityBlendIfLight=255.000000
ClarityViewMask=0.000000
ClarityViewBlendIfMask=0.000000
ClarityStrength=0.500000
ClarityLightIntensity=1.500000
BlendIfRange=0.000000
MaskContrast=0.150000
DitherStrength=0.000000
DebugMode=0.000000
Turning ClarityPerformanceMode=0/1 and MaskContrast 0/1 doesn't make a difference.
This happens the moment that I enter (really) dark areas.
Sadly it's partially fixed:
@ ClarityRGBMode=0 the problem still occurs in games like MEA & DX-MD, but the colors are intact.
@ ClarityRGBMode=1 the problem disappears, but it changes the saturation, which introduces another problem:
some colors are more saturated or less saturated then others + I use multiple shader for saturation & vibrance and for the last hour I've been trying to adjust my color shaders to retain or get close to my colors with ClarityRGBMode disabled @ 0 while ClarityRGBMode is activated @ 1 with no success.
My question/request: is it possible that you might add an option to enable/disable the saturation in ClarityRGBMode=1?
Thank you for your time reading my feedback.
In this post you said changing the performance mode fixed the issue, that was one of the reasons I got rid of the option to set it to 0. Is it the same issue or is it something similar to what conan2k was seeing with the multiply blend mode?
The saturation is the effect itself, its not something thats being added. You could try adjusting the light and dark intensity settings, you could even try using negative values which would reduce the contrast some. But any saturation you are seeing is being caused by the difference in nearby colors, thats the big difference when using the the RGB mode instead of just luma.
One thing I may try adding is a preprocessor setting that allows you to choose different values for the luma channel, then you could set it to use an average of the color channels instead of the default which favors the red and green channels. That might help you get a similar look without affecting the colors as much.
Please Log in or Create an account to join the conversation.
- Echo
Ioxa wrote:
Echo wrote: Thank you for updating some my favorite shaders. I finally got some time to try your updated Clarity2 in the hope that you might have fixed my issue below:
Warning: Spoiler!Ioxa wrote:
Echo wrote: After more testing I encountered the following problem with Clarity2:
Clarity1:
Both have the exact same settings/technique positions:
Warning: Spoiler![Clarity.fx]
ClarityRadius=2.000000
ClarityBlendMode=0.000000
ClarityOffset=10.000000
ClarityDarkIntensity=1.750000
ClarityBlendIfDark=0.000000
ClarityBlendIfLight=255.000000
ClarityViewMask=0.000000
ClarityViewBlendIfMask=0.000000
ClarityStrength=0.500000
ClarityLightIntensity=1.500000
BlendIfRange=0.000000
MaskContrast=0.150000
DitherStrength=0.000000
DebugMode=0.000000
Turning ClarityPerformanceMode=0/1 and MaskContrast 0/1 doesn't make a difference.
This happens the moment that I enter (really) dark areas.
Sadly it's partially fixed:
@ ClarityRGBMode=0 the problem still occurs in games like MEA & DX-MD, but the colors are intact.
@ ClarityRGBMode=1 the problem disappears, but it changes the saturation, which introduces another problem:
some colors are more saturated or less saturated then others + I use multiple shader for saturation & vibrance and for the last hour I've been trying to adjust my color shaders to retain or get close to my colors with ClarityRGBMode disabled @ 0 while ClarityRGBMode is activated @ 1 with no success.
My question/request: is it possible that you might add an option to enable/disable the saturation in ClarityRGBMode=1?
Thank you for your time reading my feedback.
In this post you said changing the performance mode fixed the issue, that was one of the reasons I got rid of the option to set it to 0. Is it the same issue or is it something similar to what conan2k was seeing with the multiply blend mode?
The saturation is the effect itself, its not something thats being added. You could try adjusting the light and dark intensity settings, you could even try using negative values which would reduce the contrast some. But any saturation you are seeing is being caused by the difference in nearby colors, thats the big difference when using the the RGB mode instead of just luma.
One thing I may try adding is a preprocessor setting that allows you to choose different values for the luma channel, then you could set it to use an average of the color channels instead of the default which favors the red and green channels. That might help you get a similar look without affecting the colors as much.
That's what I thought too, that by changing the performance mode to 1 the problem will completely disappear, but after more testing (yesterday) with both versions of Clarity2, while performance mode is on (Clarity2 v1), it only fixed it a bit, the glitches you saw in my screen-shots still appeared in some what dark area's, unfortunately Clarity2 v2 didn't fix it completely .
My blend mode is always set to soft-overlay, I also tried all other mods, same issue (with the glitches/saturation) + adjusting the light/dark intensity didn't effect the colouring much, just the dark & bright area's around the colouring..
I am sorry for not being able to test the previous version fully. But like I said in my previous posts, Clarity1 didn't have the glitching issue, but was missing the Mask Contrast feature which I really love and use in Clarity2. I know nothing about creating shaders and I do apologize in advance if my next sentence/question or two sound a bit dumb: does the luma-adjusting/calculating in Clarity1 work very differently then Clarity2's? Is it maybe possible to keep a Clarirty1 version with just adding Mask Contrast and maybe add the other new functions through a preprocessor setting?
Thank you again for taking the time looking into this.
After like an hour of testing and adjusting settings, I managed to find out what was causing the problem (luma-gliches), but also found a somewhat weird solution for it:
The cause:
I regret to say that it was MaskContrast. I've set it at 0.15, once I put it to 0, no more luma-gliches, but the image looked less sharp/bright without it set on 0.15 which I didn't like. So I had to try something to fix.
The weird solution:
Inside Clarity2.fx I changed
ClarityFloat sharp = 1.00-blur;
to
ClarityFloat sharp = 0.995-blur;
Tada, finally no more visible luma-glitches (only in extreme brightness) in games such ass MEA & DX-MD.
Though it made the image a bit less sharper, less details and bit darker, but adjusting just the MaskContrast from 0.15 to 0.20 did the trick.
That's all done while ClarityRGBMode=0 (is disabled) + soft-overlay blend-mode.
Hopefully you can find this helpful and maybe come up with a better solution for it.
Please Log in or Create an account to join the conversation.
- Ioxa
- Topic Author
Please Log in or Create an account to join the conversation.
- Echo
Ioxa wrote: Strange... I had run into the same problem with mask contrast in the past, it was the reason I had removed it, but I thought I fixed it. I'll have to do some more testing with it I guess. I've been using mask contrast set to 0.2, the soft light blend mode, and no blend if mask and I haven't been having any issues. I'll just have to check the math and see where things might be getting pushed out of the 0 to 1 range I guess. At least I have something to go on now.
Update:
Screens/comparison:
Reshade 3 Off/neural/untouched/.png for testing:
Reshade 3 On with Clarity2.fx @ ClarityFloat sharp = 1.00-blur; (bugged, see left-buttom-side):
Reshade 3 On with Clarity2.fx @ ClarityFloat sharp = 0.995-blur; (fixed):
Here are my .ini Reshade 3-settings for testing (All the testing is done with ClarityRGBMode @ 0 (disabled):
KeyLumaSharpen=0,0,0,0
KeyClarity2=0,0,0,0
KeyCurves=0,0,0,0
KeyLevels2=0,0,0,0
KeyTechnicolor2=0,0,0,0
KeyTonemap=0,0,0,0
KeyVibrance=0,0,0,0
KeyLiftGammaGain=0,0,0,0
Techniques=LumaSharpen,Clarity2,Tonemap,LiftGammaGain,Technicolor2,Vibrance,Curves,Levels2
TechniqueSorting=LumaSharpen,Clarity2,Tonemap,LiftGammaGain,Technicolor2,Vibrance,Curves,Levels2
[Vibrance.fx]
Vibrance=0.325000
VibranceRGBBalance=1.000000,1.000000,1.000000
[Clarity2.fx]
ClarityBlendMode=0.000000
ClarityRadius=2.000000
ClarityOffset=10.000000
ClarityDarkIntensity=0.750000
BlendIfRange=0.000000
ClarityBlendIfDark=0.000000
ClarityBlendIfLight=255.000000
ClarityStrength=0.750000
MaskContrast=0.200000
ClarityLightIntensity=1.500000
DitherStrength=0.000000
PreprocessorDefinitions=0.000000
DebugMode=0.000000
[LumaSharpen.fx]
sharp_strength=0.400000
pattern=1.000000
sharp_clamp=0.025000
offset_bias=2.400000
show_sharpen=0.000000
[Curves.fx]
Mode=2.000000
Formula=10.000000
Contrast=0.295000
[Technicolor2.fx]
Saturation=0.850000
ColorStrength=0.058824,0.058824,0.058824
Brightness=0.250000
Strength=0.850000
[Tonemap.fx]
Defog=0.000000
Bleach=0.000000
Gamma=0.750000
Exposure=0.000000
Saturation=0.495000
FogColor=0.000000,0.000000,0.000000
[LiftGammaGain.fx]
RGB_Lift=1.075000,1.075000,1.075000
RGB_Gamma=1.305000,1.305000,1.305000
RGB_Gain=1.020000,1.020000,1.020000
[Levels2.fx]
InputBlackPoint=0.058824,0.058824,0.058824
InputWhitePoint=0.882353,0.882353,0.882353
AvoidClipping=0.000000
InputGamma=0.915000,0.915000,0.915000
ColorRangeShiftSwitch=0.000000
ColorRangeShift=0.011765,0.011765,0.011765
OutputBlackPoint=0.000000,0.000000,0.000000
HighlightClipping=0.000000
OutputWhitePoint=0.901961,0.901961,0.901961
Hopefully this will help with finding a better solution.
Please Log in or Create an account to join the conversation.
- Ioxa
- Topic Author
Either way I have two solutions you can try.
This is my preferred solution, not entirely sure it will work though.
//Clarity2 by Ioxa
//Version 08.16.17a for ReShade 3.0
//>Clarity Settings<\\
#if !defined UseClarityDebug
#define UseClarityDebug 0
#endif
#if !defined ClarityRGBMode
#define ClarityRGBMode 0
#endif
#if !defined Clarity_Luma
#define Clarity_Luma 0
#endif
uniform int ClarityRadius
<
ui_type = "drag";
ui_min = 0; ui_max = 4;
ui_tooltip = "[0|1|2|3|4] Higher values will increase the radius of the effect.";
ui_step = 1.00;
> = 3;
uniform float ClarityOffset
<
ui_type = "drag";
ui_min = 1.00; ui_max = 20.00;
ui_tooltip = "Additional adjustment for the blur radius. Increasing the value will increase the radius.";
> = 8.00;
uniform int ClarityBlendMode
<
ui_type = "combo";
ui_items = "\Soft Light\0Overlay\0Hard Light\0Multiply\0Vivid Light\0Linear Light\0Addition\0";
ui_tooltip = "Blend modes determine how the clarity mask is applied to the original image";
> = 2;
uniform int ClarityBlendIfDark
<
ui_type = "drag";
ui_min = 0; ui_max = 255;
ui_tooltip = "Any pixels below this value will be excluded from the effect. Set to 50 to target mid-tones.";
ui_step = 5;
> = 50;
uniform int ClarityBlendIfLight
<
ui_type = "drag";
ui_min = 0; ui_max = 255;
ui_tooltip = "Any pixels above this value will be excluded from the effect. Set to 205 to target mid-tones.";
ui_step = 5;
> = 205;
uniform float BlendIfRange
<
ui_type = "drag";
ui_min = 0.0; ui_max = 1.0;
ui_tooltip = "Adjusts the range of the BlendIfMask.";
> = 0.2;
uniform float ClarityStrength
<
ui_type = "drag";
ui_min = 0.00; ui_max = 1.00;
ui_tooltip = "Adjusts the strength of the effect";
> = 0.400;
uniform float MaskContrast
<
ui_type = "drag";
ui_min = 0.00; ui_max = 1.00;
ui_tooltip = "Additional adjustment for the blur radius. Increasing the value will increase the radius.";
> = 0.00;
uniform float ClarityDarkIntensity
<
ui_type = "drag";
ui_min = 0.00; ui_max = 10.00;
ui_tooltip = "Adjusts the strength of dark halos.";
> = 0.400;
uniform float ClarityLightIntensity
<
ui_type = "drag";
ui_min = 0.00; ui_max = 10.00;
ui_tooltip = "Adjusts the strength of light halos.";
> = 0.000;
uniform float DitherStrength
<
ui_type = "drag";
ui_min = 0.0; ui_max = 10.0;
ui_tooltip = "Adds dithering to the ClarityMask to help reduce banding";
> = 1.0;
#if UseClarityDebug
uniform int DebugMode
<
ui_type = "combo";
ui_items = "\None\0ClarityMask\0BlendIfMask\0Blur\0";
ui_tooltip = "Some options that may be useful when adjusting settings";
> = 0;
#endif
uniform int PreprocessorDefinitions
<
ui_type = "combo";
ui_items = "\ReShade must be reloaded to activate these settings.\0UseClarityDebug=1 Activates debug options.\0ClarityRGBMode=1 Runs Clarity in RGB instead of luma.\0";
ui_tooltip = "These settings can be added to the Preprocessor Definitions in the settings tab.";
> = 0;
uniform int test
<
ui_type = "drag";
ui_min = 0; ui_max = 1;
ui_tooltip = "";
> = 0;
#include "ReShade.fxh"
#if Clarity_Luma == 0
#define ClarityLuma float3(0.32786885,0.655737705,0.0163934436)
#elif Clarity_Luma == 1
#define ClarityLuma float3(0.2126, 0.7152, 0.0722)
#elif Clarity_Luma == 2
#define ClarityLuma float3(0.3333,0.3333,0.3333)
#elif Clarity_Luma == 6
#define ClarityLuma float3(0.0,1.0,0.0)
#endif
//Offset Values
#define Offset02y float(ReShade::PixelSize.y*1.1824255238)
#define Offset03y float(ReShade::PixelSize.y*3.0293122308)
#define Offset04y float(ReShade::PixelSize.y*5.0040701377)
#define Offset02x float(ReShade::PixelSize.x*1.1824255238)
#define Offset03x float(ReShade::PixelSize.x*3.0293122308)
#define Offset04x float(ReShade::PixelSize.x*5.0040701377)
#define OffsetA2y float(ReShade::PixelSize.y*1.4584295168)
#define OffsetA3y float(ReShade::PixelSize.y*3.40398480678)
#define OffsetA4y float(ReShade::PixelSize.y*5.3518057801)
#define OffsetA5y float(ReShade::PixelSize.y*7.302940716)
#define OffsetA6y float(ReShade::PixelSize.y*9.2581597095)
#define OffsetA2x float(ReShade::PixelSize.x*1.4584295168)
#define OffsetA3x float(ReShade::PixelSize.x*3.40398480678)
#define OffsetA4x float(ReShade::PixelSize.x*5.3518057801)
#define OffsetA5x float(ReShade::PixelSize.x*7.302940716)
#define OffsetA6x float(ReShade::PixelSize.x*9.2581597095)
#define OffsetB2y float(1.4895848401*ReShade::PixelSize.y)
#define OffsetB3y float(3.4757135714*ReShade::PixelSize.y)
#define OffsetB4y float(5.4618796741*ReShade::PixelSize.y)
#define OffsetB5y float(7.4481042327*ReShade::PixelSize.y)
#define OffsetB6y float(9.4344079746*ReShade::PixelSize.y)
#define OffsetB7y float(11.420811147*ReShade::PixelSize.y)
#define OffsetB8y float(13.4073334*ReShade::PixelSize.y)
#define OffsetB9y float(15.3939936778*ReShade::PixelSize.y)
#define OffsetB10y float(17.3808101174*ReShade::PixelSize.y)
#define OffsetB11y float(19.3677999584*ReShade::PixelSize.y)
#define OffsetB2x float(1.4895848401*ReShade::PixelSize.x)
#define OffsetB3x float(3.4757135714*ReShade::PixelSize.x)
#define OffsetB4x float(5.4618796741*ReShade::PixelSize.x)
#define OffsetB5x float(7.4481042327*ReShade::PixelSize.x)
#define OffsetB6x float(9.4344079746*ReShade::PixelSize.x)
#define OffsetB7x float(11.420811147*ReShade::PixelSize.x)
#define OffsetB8x float(13.4073334*ReShade::PixelSize.x)
#define OffsetB9x float(15.3939936778*ReShade::PixelSize.x)
#define OffsetB10x float(17.3808101174*ReShade::PixelSize.x)
#define OffsetB11x float(19.3677999584*ReShade::PixelSize.x)
#define OffsetC2y float(ReShade::PixelSize.y*1.4953705027)
#define OffsetC3y float(ReShade::PixelSize.y*3.4891992113)
#define OffsetC4y float(ReShade::PixelSize.y*5.4830312105)
#define OffsetC5y float(ReShade::PixelSize.y*7.4768683759)
#define OffsetC6y float(ReShade::PixelSize.y*9.4707125766)
#define OffsetC7y float(ReShade::PixelSize.y*11.4645656736)
#define OffsetC8y float(ReShade::PixelSize.y*13.4584295168)
#define OffsetC9y float(ReShade::PixelSize.y*15.4523059431)
#define OffsetC10y float(ReShade::PixelSize.y*17.4461967743)
#define OffsetC11y float(ReShade::PixelSize.y*19.4401038149)
#define OffsetC12y float(ReShade::PixelSize.y*21.43402885)
#define OffsetC13y float(ReShade::PixelSize.y*23.4279736431)
#define OffsetC14y float(ReShade::PixelSize.y*25.4219399344)
#define OffsetC15y float(ReShade::PixelSize.y*27.4159294386)
#define OffsetC2x float(ReShade::PixelSize.x*1.4953705027)
#define OffsetC3x float(ReShade::PixelSize.x*3.4891992113)
#define OffsetC4x float(ReShade::PixelSize.x*5.4830312105)
#define OffsetC5x float(ReShade::PixelSize.x*7.4768683759)
#define OffsetC6x float(ReShade::PixelSize.x*9.4707125766)
#define OffsetC7x float(ReShade::PixelSize.x*11.4645656736)
#define OffsetC8x float(ReShade::PixelSize.x*13.4584295168)
#define OffsetC9x float(ReShade::PixelSize.x*15.4523059431)
#define OffsetC10x float(ReShade::PixelSize.x*17.4461967743)
#define OffsetC11x float(ReShade::PixelSize.x*19.4401038149)
#define OffsetC12x float(ReShade::PixelSize.x*21.43402885)
#define OffsetC13x float(ReShade::PixelSize.x*23.4279736431)
#define OffsetC14x float(ReShade::PixelSize.x*25.4219399344)
#define OffsetC15x float(ReShade::PixelSize.x*27.4159294386)
#define OffsetD2y float(ReShade::PixelSize.y*1.4953705027)
#define OffsetD3y float(ReShade::PixelSize.y*3.4891992113)
#define OffsetD4y float(ReShade::PixelSize.y*5.4830312105)
#define OffsetD5y float(ReShade::PixelSize.y*7.4768683759)
#define OffsetD6y float(ReShade::PixelSize.y*9.4707125766)
#define OffsetD7y float(ReShade::PixelSize.y*11.4645656736)
#define OffsetD8y float(ReShade::PixelSize.y*13.4584295168)
#define OffsetD9y float(ReShade::PixelSize.y*15.4523059431)
#define OffsetD10y float(ReShade::PixelSize.y*17.4461967743)
#define OffsetD11y float(ReShade::PixelSize.y*19.4661974725)
#define OffsetD12y float(ReShade::PixelSize.y*21.4627427973)
#define OffsetD13y float(ReShade::PixelSize.y*23.4592916956)
#define OffsetD14y float(ReShade::PixelSize.y*25.455844494)
#define OffsetD15y float(ReShade::PixelSize.y*27.4524015179)
#define OffsetD16y float(ReShade::PixelSize.y*29.4489630909)
#define OffsetD17y float(ReShade::PixelSize.y*31.445529535)
#define OffsetD18y float(ReShade::PixelSize.y*33.4421011704)
#define OffsetD2x float(ReShade::PixelSize.x*1.4953705027)
#define OffsetD3x float(ReShade::PixelSize.x*3.4891992113)
#define OffsetD4x float(ReShade::PixelSize.x*5.4830312105)
#define OffsetD5x float(ReShade::PixelSize.x*7.4768683759)
#define OffsetD6x float(ReShade::PixelSize.x*9.4707125766)
#define OffsetD7x float(ReShade::PixelSize.x*11.4645656736)
#define OffsetD8x float(ReShade::PixelSize.x*13.4584295168)
#define OffsetD9x float(ReShade::PixelSize.x*15.4523059431)
#define OffsetD10x float(ReShade::PixelSize.x*17.4461967743)
#define OffsetD11x float(ReShade::PixelSize.x*19.4661974725)
#define OffsetD12x float(ReShade::PixelSize.x*21.4627427973)
#define OffsetD13x float(ReShade::PixelSize.x*23.4592916956)
#define OffsetD14x float(ReShade::PixelSize.x*25.455844494)
#define OffsetD15x float(ReShade::PixelSize.x*27.4524015179)
#define OffsetD16x float(ReShade::PixelSize.x*29.4489630909)
#define OffsetD17x float(ReShade::PixelSize.x*31.445529535)
#define OffsetD18x float(ReShade::PixelSize.x*33.4421011704)
//Dithering Noise
#define noiseR float(frac((cos(dot(texcoord, float2(12.9898,78.233)))) * 43758.5453 + texcoord.x)*0.015873)-0.0079365
#define noiseG float(frac((cos(dot(texcoord, float2(-12.9898,78.233)))) * 43758.5453 + texcoord.x)*0.015873)-0.0079365
#define noiseB float(frac((sin(dot(texcoord, float2(12.9898,-78.233)))) * 43758.5453 + texcoord.x)*0.015873)-0.0079365
#if ClarityRGBMode
#define ClarityFormat RGBA8
#define CF rgb
#define ClarityFloat float3
#else
#define ClarityFormat R8
#define CF r
#define ClarityFloat float
#endif
texture Clarity2Tex{ Width = BUFFER_WIDTH*0.5; Height = BUFFER_HEIGHT*0.5; Format = ClarityFormat; };
texture Clarity2Tex2{ Width = BUFFER_WIDTH*0.5; Height = BUFFER_HEIGHT*0.5; Format = ClarityFormat; };
sampler Clarity2Sampler { Texture = Clarity2Tex; AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; MinFilter = POINT; MagFilter = LINEAR;};
sampler Clarity2Sampler2 { Texture = Clarity2Tex2; AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; MinFilter = POINT; MagFilter = LINEAR;};
float4 ClarityFinal(in float4 vpos : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target
{
ClarityFloat blur = tex2D(Clarity2Sampler, texcoord/ClarityOffset).CF;
#if UseClarityDebug
if(DebugMode == 3)
{
#if ClarityRGBMode
return float4(blur,0.0);
#else
return float4(blur,blur,blur,0.0);
#endif
}
#endif
float4 orig = tex2D(ReShade::BackBuffer, texcoord);
#if ClarityRGBMode == 0
#if Clarity_Luma == 3
float luma = max(orig.r,max(orig.g,orig.b));
#elif Clarity_Luma == 4
float luma = min(orig.r,min(orig.g,orig.b));
#elif Clarity_Luma == 5
float luma = (max(orig.r,max(orig.g,orig.b))+min(orig.r,min(orig.g,orig.b)))*0.5;
#else
float luma = dot(orig.rgb,ClarityLuma);
#endif
float3 chroma = orig.rgb/luma;
#endif
ClarityFloat sharp = saturate(1.0-blur);
if(MaskContrast)
{
#if ClarityRGBMode
float3 vivid = saturate((1-(1-orig.rgb)/(2*sharp)+orig.rgb/(2*(1-sharp)))*0.5);
sharp = (orig.rgb+sharp)*0.5;
sharp = lerp(sharp,vivid,MaskContrast);
#else
float vivid = saturate(((1-(1-luma)/(2*sharp))+(luma/(2*(1-sharp))))*0.5);
sharp = (luma+sharp)*0.5;
sharp = lerp(sharp,vivid,MaskContrast);
#endif
}
else
{
#if ClarityRGBMode
sharp = (orig.rgb+sharp)*0.5;
#else
sharp = (luma+sharp)*0.5;
#endif
}
if(ClarityDarkIntensity || ClarityLightIntensity)
{
ClarityFloat curve = sharp*sharp*sharp*(sharp*(sharp*6.0 - 15.0) + 10.0);
ClarityFloat sharpMin = lerp(sharp,curve,ClarityDarkIntensity);
ClarityFloat sharpMax = lerp(sharp,curve,ClarityLightIntensity);
ClarityFloat STEP = step(0.5,sharp);
sharp = (sharpMin*(1-STEP))+(sharpMax*STEP);
}
#if ClarityRGBMode
sharp = lerp(sharp,sharp-float3(noiseR,noiseG,noiseB),DitherStrength);
#else
sharp = lerp(sharp,sharp-noiseB,DitherStrength);
#endif
#if UseClarityDebug
if(DebugMode == 1)
{
#if ClarityRGBMode
return float4(sharp,0.0);
#else
return float4(sharp,sharp,sharp,0.0);
#endif
}
#endif
if(ClarityBlendMode == 0)
{
//softlight
//sharp = lerp(2*luma*sharp + luma*luma*(1.0-2*sharp), 2*luma*(1.0-sharp)+pow(luma,0.5)*(2*sharp-1.0), step(0.49,sharp));
#if ClarityRGBMode
float3 A = (2*orig.rgb*sharp) + (orig.rgb*orig.rgb*(1.0-2*sharp));
float3 B = (2*orig.rgb*(1.0-sharp)) + (sqrt(orig.rgb)*(2*sharp-1.0));
float3 C = step(0.49,sharp);
sharp = (A*(1.0-C))+(B*C);
#else
float A = 2*luma*sharp + luma*luma*(1.0-2*sharp);
float B = 2*luma*(1.0-sharp)+pow(luma,0.5)*(2*sharp-1.0);
float C = step(0.49,sharp);
sharp = lerp(A,B,C);
#endif
}
else
{
if(ClarityBlendMode == 1)
{
//overlay
//sharp = lerp(2*luma*sharp, 1.0 - 2*(1.0-luma)*(1.0-sharp), step(0.50,luma));
#if ClarityRGBMode
float3 A = (2*orig.rgb*sharp);
float3 B = (1.0 - 2*(1.0-orig.rgb)*(1.0-sharp));
float3 C = step(0.5,orig.rgb);
sharp = lerp(A,B,C);
#else
float A = 2*luma*sharp;
float B = 1.0 - 2*(1.0-luma)*(1.0-sharp);
float C = step(0.50,luma);
sharp = lerp(A,B,C);
#endif
}
else
{
if(ClarityBlendMode == 2)
{
//Hardlight
//sharp = lerp(2*luma*sharp, 1.0 - 2*(1.0-luma)*(1.0-sharp), step(0.50,sharp));
#if ClarityRGBMode
float3 A = 2*orig.rgb*sharp;
float3 B = 1.0 - 2*(1.0-orig.rgb)*(1.0-sharp);
float3 C = step(0.5,sharp);
sharp = lerp(A,B,C);
#else
float A = 2*luma*sharp;
float B = 1.0 - 2*(1.0-luma)*(1.0-sharp);
float C = step(0.50,sharp);
sharp = lerp(A,B,C);
#endif
}
else
{
if(ClarityBlendMode == 3)
{
//Multiply
#if ClarityRGBMode
sharp = saturate(2 * orig.rgb * sharp);
#else
sharp = saturate(2 * luma * sharp);
#endif
}
else
{
if(ClarityBlendMode == 4)
{
//vivid light
//sharp = lerp(2*luma*sharp, luma/(2*(1-sharp)), step(0.5,sharp));
#if ClarityRGBMode
float3 A = 2*orig.rgb*sharp;
float3 B = orig.rgb/(2*(1-sharp));
float3 C = step(0.50,sharp);
sharp = lerp(A,B,C);
#else
float A = 2*luma*sharp;
float B = luma/(2*(1-sharp));
float C = step(0.50,sharp);
sharp = lerp(A,B,C);
#endif
}
else
{
if(ClarityBlendMode == 5)
{
//Linear Light
//sharp = luma-1.0 + (2.0*sharp);
#if ClarityRGBMode
sharp = orig.rgb + 2.0*sharp-1.0;
#else
sharp = luma + 2.0*sharp-1.0;
#endif
}
else
{
if(ClarityBlendMode == 6)
{
//Addition
#if ClarityRGBMode
sharp = saturate(orig.rgb + (sharp - 0.5));
#else
sharp = saturate(luma + (sharp - 0.5));
#endif
}
}
}
}
}
}
}
if( ClarityBlendIfDark || ClarityBlendIfLight < 255)
{
float ClarityBlendIfD = ((255-ClarityBlendIfDark)/255.0);
float ClarityBlendIfL = (ClarityBlendIfLight/255.0);
ClarityFloat mask = 1.0;
float range;
if(ClarityBlendIfDark)
{
range = ClarityBlendIfD*BlendIfRange;
#if ClarityRGBMode
float3 mix = 1-orig.rgb;
mask -= smoothstep(ClarityBlendIfD-(range),ClarityBlendIfD+(range),mix);
#else
float mix = 1.0-luma;
mask -= smoothstep(ClarityBlendIfD-(range),ClarityBlendIfD+(range),mix);
#endif
}
if(ClarityBlendIfLight)
{
range = ClarityBlendIfL*BlendIfRange;
#if ClarityRGBMode
float3 mix = orig.rgb;
mask = lerp(mask,0.0,smoothstep(ClarityBlendIfL-range, ClarityBlendIfL+range, mix));
#else
float mix = luma;
mask = lerp(mask,0.0,smoothstep(ClarityBlendIfL-range, ClarityBlendIfL+range, mix));
#endif
}
#if ClarityRGBMode
sharp = lerp(orig.rgb,sharp,mask);
#else
sharp = lerp(luma,sharp,mask);
#endif
#if UseClarityDebug
if(DebugMode == 2)
{
#if ClarityRGBMode
return float4(mask,0.0);
#else
return float4(mask,mask,mask,0.0);
#endif
}
#endif
}
#if ClarityRGBMode
orig.rgb = lerp(orig.rgb, sharp, ClarityStrength);
return saturate(orig);
#else
luma = lerp(luma, sharp, ClarityStrength);
return saturate(float4(luma*chroma,0.0));
#endif
}
ClarityFloat Clarity1(in float4 vpos : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target
{
float3 color = tex2D(ReShade::BackBuffer, texcoord*ClarityOffset).rgb;
#if ClarityRGBMode
return saturate(color);
#else
#if Clarity_Luma == 3
return saturate(max(color.r,max(color.g,color.b)));
#elif Clarity_Luma == 4
return saturate(min(color.r,min(color.g,color.b)));
#elif Clarity_Luma == 5
return saturate((max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)))*0.5);
#else
return saturate(dot(color.rgb,ClarityLuma));
#endif
#endif
}
ClarityFloat Clarity2(in float4 vpos : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target
{
ClarityFloat blur = tex2D(Clarity2Sampler, texcoord).CF;
float2 coord;
if(ClarityRadius == 2)
{
static const float offset[11] = { 0.0, OffsetB2y, OffsetB3y, OffsetB4y, OffsetB5y, OffsetB6y, OffsetB7y, OffsetB8y, OffsetB9y, OffsetB10y, OffsetB11y };
static const float weight[11] = { 0.06649, 0.1284697563, 0.111918249, 0.0873132676, 0.0610011113, 0.0381655709, 0.0213835661, 0.0107290241, 0.0048206869, 0.0019396469, 0.0006988718 };
blur *= weight[0];
[loop]
for(int i = 1; i < 11; ++i)
{
coord = float2(0.0, offset[i]);
blur += tex2Dlod(Clarity2Sampler, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 3)
{
static const float offset[15] = { 0.0, OffsetC2y, OffsetC3y, OffsetC4y, OffsetC5y, OffsetC6y, OffsetC7y, OffsetC8y, OffsetC9y, OffsetC10y, OffsetC11y, OffsetC12y, OffsetC13y, OffsetC14y, OffsetC15y };
static const float weight[15] = { 0.0443266667, 0.0872994708, 0.0820892038, 0.0734818355, 0.0626171681, 0.0507956191, 0.0392263968, 0.0288369812, 0.0201808877, 0.0134446557, 0.0085266392, 0.0051478359, 0.0029586248, 0.0016187257, 0.0008430913 };
blur *= weight[0];
[loop]
for(int i = 1; i < 15; ++i)
{
coord = float2(0.0, offset[i]);
blur += tex2Dlod(Clarity2Sampler, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 4)
{
static const float offset[18] = { 0.0, OffsetD2y, OffsetD3y, OffsetD4y, OffsetD5y, OffsetD6y, OffsetD7y, OffsetD8y, OffsetD9y, OffsetD10y, OffsetD11y, OffsetD12y, OffsetD13y, OffsetD14y, OffsetD15y, OffsetD16y, OffsetD17y, OffsetD18y };
static const float weight[18] = { 0.033245, 0.0659162217, 0.0636705814, 0.0598194658, 0.0546642566, 0.0485871646, 0.0420045997, 0.0353207015, 0.0288880982, 0.0229808311, 0.0177815511, 0.013382297, 0.0097960001, 0.0069746748, 0.0048301008, 0.0032534598, 0.0021315311, 0.0013582974 };
blur *= weight[0];
[loop]
for(int i = 1; i < 18; ++i)
{
coord = float2(0.0, offset[i]);
blur += tex2Dlod(Clarity2Sampler, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 1)
{
static const float offset[6] = { 0.0, OffsetA2y, OffsetA3y, OffsetA4y, OffsetA5y, OffsetA6y };
static const float weight[6] = { 0.13298, 0.23227575, 0.1353261595, 0.0511557427, 0.01253922, 0.0019913644 };
blur *= weight[0];
[loop]
for(int i = 1; i < 6; ++i)
{
coord = float2(0.0, offset[i]);
blur += tex2Dlod(Clarity2Sampler, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 0)
{
static const float offset[4] = { 0.0, Offset02y, Offset03y, Offset04y };
static const float weight[4] = { 0.39894, 0.2959599993, 0.0045656525, 0.00000149278686458842 };
blur *= weight[0];
[loop]
for(int i = 1; i < 4; ++i)
{
coord = float2(0.0, offset[i]);
blur += tex2Dlod(Clarity2Sampler, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
}
}
}
}
return saturate(blur);
}
ClarityFloat Clarity3(in float4 vpos : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target
{
ClarityFloat blur = tex2D(Clarity2Sampler2, texcoord).CF;
float2 coord;
if(ClarityRadius == 2)
{
static const float offset[11] = { 0.0, OffsetB2x, OffsetB3x, OffsetB4x, OffsetB5x, OffsetB6x, OffsetB7x, OffsetB8x, OffsetB9x, OffsetB10x, OffsetB11x };
static const float weight[11] = { 0.06649, 0.1284697563, 0.111918249, 0.0873132676, 0.0610011113, 0.0381655709, 0.0213835661, 0.0107290241, 0.0048206869, 0.0019396469, 0.0006988718 };
blur *= weight[0];
[loop]
for(int i = 1; i < 11; ++i)
{
coord = float2(offset[i],0.0);
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 3)
{
static const float offset[15] = { 0.0, OffsetC2x, OffsetC3x, OffsetC4x, OffsetC5x, OffsetC6x, OffsetC7x, OffsetC8x, OffsetC9x, OffsetC10x, OffsetC11x, OffsetC12x, OffsetC13x, OffsetC14x, OffsetC15x };
static const float weight[15] = { 0.0443266667, 0.0872994708, 0.0820892038, 0.0734818355, 0.0626171681, 0.0507956191, 0.0392263968, 0.0288369812, 0.0201808877, 0.0134446557, 0.0085266392, 0.0051478359, 0.0029586248, 0.0016187257, 0.0008430913 };
blur *= weight[0];
[loop]
for(int i = 1; i < 15; ++i)
{
coord = float2(offset[i],0.0);
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 4)
{
static const float offset[18] = { 0.0, OffsetD2x, OffsetD3x, OffsetD4x, OffsetD5x, OffsetD6x, OffsetD7x, OffsetD8x, OffsetD9x, OffsetD10x, OffsetD11x, OffsetD12x, OffsetD13x, OffsetD14x, OffsetD15x, OffsetD16x, OffsetD17x, OffsetD18x };
static const float weight[18] = { 0.033245, 0.0659162217, 0.0636705814, 0.0598194658, 0.0546642566, 0.0485871646, 0.0420045997, 0.0353207015, 0.0288880982, 0.0229808311, 0.0177815511, 0.013382297, 0.0097960001, 0.0069746748, 0.0048301008, 0.0032534598, 0.0021315311, 0.0013582974 };
blur *= weight[0];
[loop]
for(int i = 1; i < 18; ++i)
{
coord = float2(offset[i],0.0);
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 1)
{
static const float offset[6] = { 0.0, OffsetA2x, OffsetA3x, OffsetA4x, OffsetA5x, OffsetA6x };
static const float weight[6] = { 0.13298, 0.23227575, 0.1353261595, 0.0511557427, 0.01253922, 0.0019913644 };
blur *= weight[0];
[loop]
for(int i = 1; i < 6; ++i)
{
coord = float2(offset[i],0.0);
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 0)
{
static const float offset[4] = { 0.0, Offset02x, Offset03x, Offset04x };
static const float weight[4] = { 0.39894, 0.2959599993, 0.0045656525, 0.00000149278686458842 };
blur *= weight[0];
[loop]
for(int i = 1; i < 4; ++i)
{
coord = float2(offset[i],0.0);
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
}
}
}
}
return saturate(blur);
}
technique Clarity2
{
pass Clarity1
{
VertexShader = PostProcessVS;
PixelShader = Clarity1;
RenderTarget = Clarity2Tex;
}
pass Clarity2
{
VertexShader = PostProcessVS;
PixelShader = Clarity2;
RenderTarget = Clarity2Tex2;
}
pass Clarity3
{
VertexShader = PostProcessVS;
PixelShader = Clarity3;
RenderTarget = Clarity2Tex;
}
pass ClarityFinal
{
VertexShader = PostProcessVS;
PixelShader = ClarityFinal;
}
}
And I'm pretty sure this will fix it but I'd rather not do it this way.
//Clarity2 by Ioxa
//Version 08.16.17b for ReShade 3.0
//>Clarity Settings<\\
#if !defined UseClarityDebug
#define UseClarityDebug 0
#endif
#if !defined ClarityRGBMode
#define ClarityRGBMode 0
#endif
#if !defined Clarity_Luma
#define Clarity_Luma 0
#endif
uniform int ClarityRadius
<
ui_type = "drag";
ui_min = 0; ui_max = 4;
ui_tooltip = "[0|1|2|3|4] Higher values will increase the radius of the effect.";
ui_step = 1.00;
> = 3;
uniform float ClarityOffset
<
ui_type = "drag";
ui_min = 1.00; ui_max = 20.00;
ui_tooltip = "Additional adjustment for the blur radius. Increasing the value will increase the radius.";
> = 8.00;
uniform int ClarityBlendMode
<
ui_type = "combo";
ui_items = "\Soft Light\0Overlay\0Hard Light\0Multiply\0Vivid Light\0Linear Light\0Addition\0";
ui_tooltip = "Blend modes determine how the clarity mask is applied to the original image";
> = 2;
uniform int ClarityBlendIfDark
<
ui_type = "drag";
ui_min = 0; ui_max = 255;
ui_tooltip = "Any pixels below this value will be excluded from the effect. Set to 50 to target mid-tones.";
ui_step = 5;
> = 50;
uniform int ClarityBlendIfLight
<
ui_type = "drag";
ui_min = 0; ui_max = 255;
ui_tooltip = "Any pixels above this value will be excluded from the effect. Set to 205 to target mid-tones.";
ui_step = 5;
> = 205;
uniform float BlendIfRange
<
ui_type = "drag";
ui_min = 0.0; ui_max = 1.0;
ui_tooltip = "Adjusts the range of the BlendIfMask.";
> = 0.2;
uniform float ClarityStrength
<
ui_type = "drag";
ui_min = 0.00; ui_max = 1.00;
ui_tooltip = "Adjusts the strength of the effect";
> = 0.400;
uniform float MaskContrast
<
ui_type = "drag";
ui_min = 0.00; ui_max = 1.00;
ui_tooltip = "Additional adjustment for the blur radius. Increasing the value will increase the radius.";
> = 0.00;
uniform float ClarityDarkIntensity
<
ui_type = "drag";
ui_min = 0.00; ui_max = 10.00;
ui_tooltip = "Adjusts the strength of dark halos.";
> = 0.400;
uniform float ClarityLightIntensity
<
ui_type = "drag";
ui_min = 0.00; ui_max = 10.00;
ui_tooltip = "Adjusts the strength of light halos.";
> = 0.000;
uniform float DitherStrength
<
ui_type = "drag";
ui_min = 0.0; ui_max = 10.0;
ui_tooltip = "Adds dithering to the ClarityMask to help reduce banding";
> = 1.0;
#if UseClarityDebug
uniform int DebugMode
<
ui_type = "combo";
ui_items = "\None\0ClarityMask\0BlendIfMask\0Blur\0";
ui_tooltip = "Some options that may be useful when adjusting settings";
> = 0;
#endif
uniform int PreprocessorDefinitions
<
ui_type = "combo";
ui_items = "\ReShade must be reloaded to activate these settings.\0UseClarityDebug=1 Activates debug options.\0ClarityRGBMode=1 Runs Clarity in RGB instead of luma.\0";
ui_tooltip = "These settings can be added to the Preprocessor Definitions in the settings tab.";
> = 0;
#include "ReShade.fxh"
#if Clarity_Luma == 0
#define ClarityLuma float3(0.32786885,0.655737705,0.0163934436)
#elif Clarity_Luma == 1
#define ClarityLuma float3(0.2126, 0.7152, 0.0722)
#elif Clarity_Luma == 2
#define ClarityLuma float3(0.3333,0.3333,0.3333)
#elif Clarity_Luma == 6
#define ClarityLuma float3(0.0,1.0,0.0)
#endif
//Offset Values
#define Offset02y float(ReShade::PixelSize.y*1.1824255238)
#define Offset03y float(ReShade::PixelSize.y*3.0293122308)
#define Offset04y float(ReShade::PixelSize.y*5.0040701377)
#define Offset02x float(ReShade::PixelSize.x*1.1824255238)
#define Offset03x float(ReShade::PixelSize.x*3.0293122308)
#define Offset04x float(ReShade::PixelSize.x*5.0040701377)
#define OffsetA2y float(ReShade::PixelSize.y*1.4584295168)
#define OffsetA3y float(ReShade::PixelSize.y*3.40398480678)
#define OffsetA4y float(ReShade::PixelSize.y*5.3518057801)
#define OffsetA5y float(ReShade::PixelSize.y*7.302940716)
#define OffsetA6y float(ReShade::PixelSize.y*9.2581597095)
#define OffsetA2x float(ReShade::PixelSize.x*1.4584295168)
#define OffsetA3x float(ReShade::PixelSize.x*3.40398480678)
#define OffsetA4x float(ReShade::PixelSize.x*5.3518057801)
#define OffsetA5x float(ReShade::PixelSize.x*7.302940716)
#define OffsetA6x float(ReShade::PixelSize.x*9.2581597095)
#define OffsetB2y float(1.4895848401*ReShade::PixelSize.y)
#define OffsetB3y float(3.4757135714*ReShade::PixelSize.y)
#define OffsetB4y float(5.4618796741*ReShade::PixelSize.y)
#define OffsetB5y float(7.4481042327*ReShade::PixelSize.y)
#define OffsetB6y float(9.4344079746*ReShade::PixelSize.y)
#define OffsetB7y float(11.420811147*ReShade::PixelSize.y)
#define OffsetB8y float(13.4073334*ReShade::PixelSize.y)
#define OffsetB9y float(15.3939936778*ReShade::PixelSize.y)
#define OffsetB10y float(17.3808101174*ReShade::PixelSize.y)
#define OffsetB11y float(19.3677999584*ReShade::PixelSize.y)
#define OffsetB2x float(1.4895848401*ReShade::PixelSize.x)
#define OffsetB3x float(3.4757135714*ReShade::PixelSize.x)
#define OffsetB4x float(5.4618796741*ReShade::PixelSize.x)
#define OffsetB5x float(7.4481042327*ReShade::PixelSize.x)
#define OffsetB6x float(9.4344079746*ReShade::PixelSize.x)
#define OffsetB7x float(11.420811147*ReShade::PixelSize.x)
#define OffsetB8x float(13.4073334*ReShade::PixelSize.x)
#define OffsetB9x float(15.3939936778*ReShade::PixelSize.x)
#define OffsetB10x float(17.3808101174*ReShade::PixelSize.x)
#define OffsetB11x float(19.3677999584*ReShade::PixelSize.x)
#define OffsetC2y float(ReShade::PixelSize.y*1.4953705027)
#define OffsetC3y float(ReShade::PixelSize.y*3.4891992113)
#define OffsetC4y float(ReShade::PixelSize.y*5.4830312105)
#define OffsetC5y float(ReShade::PixelSize.y*7.4768683759)
#define OffsetC6y float(ReShade::PixelSize.y*9.4707125766)
#define OffsetC7y float(ReShade::PixelSize.y*11.4645656736)
#define OffsetC8y float(ReShade::PixelSize.y*13.4584295168)
#define OffsetC9y float(ReShade::PixelSize.y*15.4523059431)
#define OffsetC10y float(ReShade::PixelSize.y*17.4461967743)
#define OffsetC11y float(ReShade::PixelSize.y*19.4401038149)
#define OffsetC12y float(ReShade::PixelSize.y*21.43402885)
#define OffsetC13y float(ReShade::PixelSize.y*23.4279736431)
#define OffsetC14y float(ReShade::PixelSize.y*25.4219399344)
#define OffsetC15y float(ReShade::PixelSize.y*27.4159294386)
#define OffsetC2x float(ReShade::PixelSize.x*1.4953705027)
#define OffsetC3x float(ReShade::PixelSize.x*3.4891992113)
#define OffsetC4x float(ReShade::PixelSize.x*5.4830312105)
#define OffsetC5x float(ReShade::PixelSize.x*7.4768683759)
#define OffsetC6x float(ReShade::PixelSize.x*9.4707125766)
#define OffsetC7x float(ReShade::PixelSize.x*11.4645656736)
#define OffsetC8x float(ReShade::PixelSize.x*13.4584295168)
#define OffsetC9x float(ReShade::PixelSize.x*15.4523059431)
#define OffsetC10x float(ReShade::PixelSize.x*17.4461967743)
#define OffsetC11x float(ReShade::PixelSize.x*19.4401038149)
#define OffsetC12x float(ReShade::PixelSize.x*21.43402885)
#define OffsetC13x float(ReShade::PixelSize.x*23.4279736431)
#define OffsetC14x float(ReShade::PixelSize.x*25.4219399344)
#define OffsetC15x float(ReShade::PixelSize.x*27.4159294386)
#define OffsetD2y float(ReShade::PixelSize.y*1.4953705027)
#define OffsetD3y float(ReShade::PixelSize.y*3.4891992113)
#define OffsetD4y float(ReShade::PixelSize.y*5.4830312105)
#define OffsetD5y float(ReShade::PixelSize.y*7.4768683759)
#define OffsetD6y float(ReShade::PixelSize.y*9.4707125766)
#define OffsetD7y float(ReShade::PixelSize.y*11.4645656736)
#define OffsetD8y float(ReShade::PixelSize.y*13.4584295168)
#define OffsetD9y float(ReShade::PixelSize.y*15.4523059431)
#define OffsetD10y float(ReShade::PixelSize.y*17.4461967743)
#define OffsetD11y float(ReShade::PixelSize.y*19.4661974725)
#define OffsetD12y float(ReShade::PixelSize.y*21.4627427973)
#define OffsetD13y float(ReShade::PixelSize.y*23.4592916956)
#define OffsetD14y float(ReShade::PixelSize.y*25.455844494)
#define OffsetD15y float(ReShade::PixelSize.y*27.4524015179)
#define OffsetD16y float(ReShade::PixelSize.y*29.4489630909)
#define OffsetD17y float(ReShade::PixelSize.y*31.445529535)
#define OffsetD18y float(ReShade::PixelSize.y*33.4421011704)
#define OffsetD2x float(ReShade::PixelSize.x*1.4953705027)
#define OffsetD3x float(ReShade::PixelSize.x*3.4891992113)
#define OffsetD4x float(ReShade::PixelSize.x*5.4830312105)
#define OffsetD5x float(ReShade::PixelSize.x*7.4768683759)
#define OffsetD6x float(ReShade::PixelSize.x*9.4707125766)
#define OffsetD7x float(ReShade::PixelSize.x*11.4645656736)
#define OffsetD8x float(ReShade::PixelSize.x*13.4584295168)
#define OffsetD9x float(ReShade::PixelSize.x*15.4523059431)
#define OffsetD10x float(ReShade::PixelSize.x*17.4461967743)
#define OffsetD11x float(ReShade::PixelSize.x*19.4661974725)
#define OffsetD12x float(ReShade::PixelSize.x*21.4627427973)
#define OffsetD13x float(ReShade::PixelSize.x*23.4592916956)
#define OffsetD14x float(ReShade::PixelSize.x*25.455844494)
#define OffsetD15x float(ReShade::PixelSize.x*27.4524015179)
#define OffsetD16x float(ReShade::PixelSize.x*29.4489630909)
#define OffsetD17x float(ReShade::PixelSize.x*31.445529535)
#define OffsetD18x float(ReShade::PixelSize.x*33.4421011704)
//Dithering Noise
#define noiseR float(frac((cos(dot(texcoord, float2(12.9898,78.233)))) * 43758.5453 + texcoord.x)*0.015873)-0.0079365
#define noiseG float(frac((cos(dot(texcoord, float2(-12.9898,78.233)))) * 43758.5453 + texcoord.x)*0.015873)-0.0079365
#define noiseB float(frac((sin(dot(texcoord, float2(12.9898,-78.233)))) * 43758.5453 + texcoord.x)*0.015873)-0.0079365
#if ClarityRGBMode
#define ClarityFormat RGBA8
#define CF rgb
#define ClarityFloat float3
#else
#define ClarityFormat R8
#define CF r
#define ClarityFloat float
#endif
texture Clarity2Tex{ Width = BUFFER_WIDTH*0.5; Height = BUFFER_HEIGHT*0.5; Format = ClarityFormat; };
texture Clarity2Tex2{ Width = BUFFER_WIDTH*0.5; Height = BUFFER_HEIGHT*0.5; Format = ClarityFormat; };
sampler Clarity2Sampler { Texture = Clarity2Tex; AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; MinFilter = POINT; MagFilter = LINEAR;};
sampler Clarity2Sampler2 { Texture = Clarity2Tex2; AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; MinFilter = POINT; MagFilter = LINEAR;};
float4 ClarityFinal(in float4 vpos : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target
{
ClarityFloat blur = tex2D(Clarity2Sampler, texcoord/ClarityOffset).CF;
#if UseClarityDebug
if(DebugMode == 3)
{
#if ClarityRGBMode
return float4(blur,0.0);
#else
return float4(blur,blur,blur,0.0);
#endif
}
#endif
float4 orig = tex2D(ReShade::BackBuffer, texcoord);
#if ClarityRGBMode == 0
#if Clarity_Luma == 3
float luma = max(orig.r,max(orig.g,orig.b));
#elif Clarity_Luma == 4
float luma = min(orig.r,min(orig.g,orig.b));
#elif Clarity_Luma == 5
float luma = (max(orig.r,max(orig.g,orig.b))+min(orig.r,min(orig.g,orig.b)))*0.5;
#else
float luma = dot(orig.rgb,ClarityLuma);
#endif
float3 chroma = orig.rgb-luma;
#endif
ClarityFloat sharp = 1.0-blur;
if(MaskContrast)
{
#if ClarityRGBMode
float3 vivid = saturate((1-(1-orig.rgb)/(2*sharp)+orig.rgb/(2*(1-sharp)))*0.5);
sharp = (orig.rgb+sharp)*0.5;
sharp = lerp(sharp,vivid,MaskContrast);
#else
float vivid = saturate(((1-(1-luma)/(2*sharp))+(luma/(2*(1-sharp))))*0.5);
sharp = (luma+sharp)*0.5;
sharp = lerp(sharp,vivid,MaskContrast);
#endif
}
else
{
#if ClarityRGBMode
sharp = (orig.rgb+sharp)*0.5;
#else
sharp = (luma+sharp)*0.5;
#endif
}
if(ClarityDarkIntensity || ClarityLightIntensity)
{
ClarityFloat curve = sharp*sharp*sharp*(sharp*(sharp*6.0 - 15.0) + 10.0);
ClarityFloat sharpMin = lerp(sharp,curve,ClarityDarkIntensity);
ClarityFloat sharpMax = lerp(sharp,curve,ClarityLightIntensity);
ClarityFloat STEP = step(0.5,sharp);
sharp = (sharpMin*(1-STEP))+(sharpMax*STEP);
}
#if ClarityRGBMode
sharp = lerp(sharp,sharp-float3(noiseR,noiseG,noiseB),DitherStrength);
#else
sharp = lerp(sharp,sharp-noiseB,DitherStrength);
#endif
#if UseClarityDebug
if(DebugMode == 1)
{
#if ClarityRGBMode
return float4(sharp,0.0);
#else
return float4(sharp,sharp,sharp,0.0);
#endif
}
#endif
if(ClarityBlendMode == 0)
{
//softlight
//sharp = lerp(2*luma*sharp + luma*luma*(1.0-2*sharp), 2*luma*(1.0-sharp)+pow(luma,0.5)*(2*sharp-1.0), step(0.49,sharp));
#if ClarityRGBMode
float3 A = (2*orig.rgb*sharp) + (orig.rgb*orig.rgb*(1.0-2*sharp));
float3 B = (2*orig.rgb*(1.0-sharp)) + (sqrt(orig.rgb)*(2*sharp-1.0));
float3 C = step(0.49,sharp);
sharp = (A*(1.0-C))+(B*C);
#else
float A = 2*luma*sharp + luma*luma*(1.0-2*sharp);
float B = 2*luma*(1.0-sharp)+pow(luma,0.5)*(2*sharp-1.0);
float C = step(0.49,sharp);
sharp = lerp(A,B,C);
#endif
}
else
{
if(ClarityBlendMode == 1)
{
//overlay
//sharp = lerp(2*luma*sharp, 1.0 - 2*(1.0-luma)*(1.0-sharp), step(0.50,luma));
#if ClarityRGBMode
float3 A = (2*orig.rgb*sharp);
float3 B = (1.0 - 2*(1.0-orig.rgb)*(1.0-sharp));
float3 C = step(0.5,orig.rgb);
sharp = lerp(A,B,C);
#else
float A = 2*luma*sharp;
float B = 1.0 - 2*(1.0-luma)*(1.0-sharp);
float C = step(0.50,luma);
sharp = lerp(A,B,C);
#endif
}
else
{
if(ClarityBlendMode == 2)
{
//Hardlight
//sharp = lerp(2*luma*sharp, 1.0 - 2*(1.0-luma)*(1.0-sharp), step(0.50,sharp));
#if ClarityRGBMode
float3 A = 2*orig.rgb*sharp;
float3 B = 1.0 - 2*(1.0-orig.rgb)*(1.0-sharp);
float3 C = step(0.5,sharp);
sharp = lerp(A,B,C);
#else
float A = 2*luma*sharp;
float B = 1.0 - 2*(1.0-luma)*(1.0-sharp);
float C = step(0.50,sharp);
sharp = lerp(A,B,C);
#endif
}
else
{
if(ClarityBlendMode == 3)
{
//Multiply
#if ClarityRGBMode
sharp = saturate(2 * orig.rgb * sharp);
#else
sharp = saturate(2 * luma * sharp);
#endif
}
else
{
if(ClarityBlendMode == 4)
{
//vivid light
//sharp = lerp(2*luma*sharp, luma/(2*(1-sharp)), step(0.5,sharp));
#if ClarityRGBMode
float3 A = 2*orig.rgb*sharp;
float3 B = orig.rgb/(2*(1-sharp));
float3 C = step(0.50,sharp);
sharp = lerp(A,B,C);
#else
float A = 2*luma*sharp;
float B = luma/(2*(1-sharp));
float C = step(0.50,sharp);
sharp = lerp(A,B,C);
#endif
}
else
{
if(ClarityBlendMode == 5)
{
//Linear Light
//sharp = luma-1.0 + (2.0*sharp);
#if ClarityRGBMode
sharp = orig.rgb + 2.0*sharp-1.0;
#else
sharp = luma + 2.0*sharp-1.0;
#endif
}
else
{
if(ClarityBlendMode == 6)
{
//Addition
#if ClarityRGBMode
sharp = saturate(orig.rgb + (sharp - 0.5));
#else
sharp = saturate(luma + (sharp - 0.5));
#endif
}
}
}
}
}
}
}
if( ClarityBlendIfDark || ClarityBlendIfLight < 255)
{
float ClarityBlendIfD = ((255-ClarityBlendIfDark)/255.0);
float ClarityBlendIfL = (ClarityBlendIfLight/255.0);
ClarityFloat mask = 1.0;
float range;
if(ClarityBlendIfDark)
{
range = ClarityBlendIfD*BlendIfRange;
#if ClarityRGBMode
float3 mix = 1-orig.rgb;
mask -= smoothstep(ClarityBlendIfD-(range),ClarityBlendIfD+(range),mix);
#else
float mix = 1.0-luma;
mask -= smoothstep(ClarityBlendIfD-(range),ClarityBlendIfD+(range),mix);
#endif
}
if(ClarityBlendIfLight)
{
range = ClarityBlendIfL*BlendIfRange;
#if ClarityRGBMode
float3 mix = orig.rgb;
mask = lerp(mask,0.0,smoothstep(ClarityBlendIfL-range, ClarityBlendIfL+range, mix));
#else
float mix = luma;
mask = lerp(mask,0.0,smoothstep(ClarityBlendIfL-range, ClarityBlendIfL+range, mix));
#endif
}
#if ClarityRGBMode
sharp = lerp(orig.rgb,sharp,mask);
#else
sharp = lerp(luma,sharp,mask);
#endif
#if UseClarityDebug
if(DebugMode == 2)
{
#if ClarityRGBMode
return float4(mask,0.0);
#else
return float4(mask,mask,mask,0.0);
#endif
}
#endif
}
#if ClarityRGBMode
orig.rgb = lerp(orig.rgb, sharp, ClarityStrength);
return orig;
#else
luma = lerp(luma, sharp, ClarityStrength);
return float4(luma+chroma,0.0);
#endif
}
ClarityFloat Clarity1(in float4 vpos : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target
{
float3 color = tex2D(ReShade::BackBuffer, texcoord*ClarityOffset).rgb;
#if ClarityRGBMode
return saturate(color);
#else
#if Clarity_Luma == 3
return saturate(max(color.r,max(color.g,color.b)));
#elif Clarity_Luma == 4
return saturate(min(color.r,min(color.g,color.b)));
#elif Clarity_Luma == 5
return saturate((max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)))*0.5);
#else
return saturate(dot(color.rgb,ClarityLuma));
#endif
#endif
}
ClarityFloat Clarity2(in float4 vpos : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target
{
ClarityFloat blur = tex2D(Clarity2Sampler, texcoord).CF;
float2 coord;
if(ClarityRadius == 2)
{
static const float offset[11] = { 0.0, OffsetB2y, OffsetB3y, OffsetB4y, OffsetB5y, OffsetB6y, OffsetB7y, OffsetB8y, OffsetB9y, OffsetB10y, OffsetB11y };
static const float weight[11] = { 0.06649, 0.1284697563, 0.111918249, 0.0873132676, 0.0610011113, 0.0381655709, 0.0213835661, 0.0107290241, 0.0048206869, 0.0019396469, 0.0006988718 };
blur *= weight[0];
[loop]
for(int i = 1; i < 11; ++i)
{
coord = float2(0.0, offset[i]);
blur += tex2Dlod(Clarity2Sampler, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 3)
{
static const float offset[15] = { 0.0, OffsetC2y, OffsetC3y, OffsetC4y, OffsetC5y, OffsetC6y, OffsetC7y, OffsetC8y, OffsetC9y, OffsetC10y, OffsetC11y, OffsetC12y, OffsetC13y, OffsetC14y, OffsetC15y };
static const float weight[15] = { 0.0443266667, 0.0872994708, 0.0820892038, 0.0734818355, 0.0626171681, 0.0507956191, 0.0392263968, 0.0288369812, 0.0201808877, 0.0134446557, 0.0085266392, 0.0051478359, 0.0029586248, 0.0016187257, 0.0008430913 };
blur *= weight[0];
[loop]
for(int i = 1; i < 15; ++i)
{
coord = float2(0.0, offset[i]);
blur += tex2Dlod(Clarity2Sampler, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 4)
{
static const float offset[18] = { 0.0, OffsetD2y, OffsetD3y, OffsetD4y, OffsetD5y, OffsetD6y, OffsetD7y, OffsetD8y, OffsetD9y, OffsetD10y, OffsetD11y, OffsetD12y, OffsetD13y, OffsetD14y, OffsetD15y, OffsetD16y, OffsetD17y, OffsetD18y };
static const float weight[18] = { 0.033245, 0.0659162217, 0.0636705814, 0.0598194658, 0.0546642566, 0.0485871646, 0.0420045997, 0.0353207015, 0.0288880982, 0.0229808311, 0.0177815511, 0.013382297, 0.0097960001, 0.0069746748, 0.0048301008, 0.0032534598, 0.0021315311, 0.0013582974 };
blur *= weight[0];
[loop]
for(int i = 1; i < 18; ++i)
{
coord = float2(0.0, offset[i]);
blur += tex2Dlod(Clarity2Sampler, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 1)
{
static const float offset[6] = { 0.0, OffsetA2y, OffsetA3y, OffsetA4y, OffsetA5y, OffsetA6y };
static const float weight[6] = { 0.13298, 0.23227575, 0.1353261595, 0.0511557427, 0.01253922, 0.0019913644 };
blur *= weight[0];
[loop]
for(int i = 1; i < 6; ++i)
{
coord = float2(0.0, offset[i]);
blur += tex2Dlod(Clarity2Sampler, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 0)
{
static const float offset[4] = { 0.0, Offset02y, Offset03y, Offset04y };
static const float weight[4] = { 0.39894, 0.2959599993, 0.0045656525, 0.00000149278686458842 };
blur *= weight[0];
[loop]
for(int i = 1; i < 4; ++i)
{
coord = float2(0.0, offset[i]);
blur += tex2Dlod(Clarity2Sampler, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
}
}
}
}
return blur;
}
ClarityFloat Clarity3(in float4 vpos : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target
{
ClarityFloat blur = tex2D(Clarity2Sampler2, texcoord).CF;
float2 coord;
if(ClarityRadius == 2)
{
static const float offset[11] = { 0.0, OffsetB2x, OffsetB3x, OffsetB4x, OffsetB5x, OffsetB6x, OffsetB7x, OffsetB8x, OffsetB9x, OffsetB10x, OffsetB11x };
static const float weight[11] = { 0.06649, 0.1284697563, 0.111918249, 0.0873132676, 0.0610011113, 0.0381655709, 0.0213835661, 0.0107290241, 0.0048206869, 0.0019396469, 0.0006988718 };
blur *= weight[0];
[loop]
for(int i = 1; i < 11; ++i)
{
coord = float2(offset[i],0.0);
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 3)
{
static const float offset[15] = { 0.0, OffsetC2x, OffsetC3x, OffsetC4x, OffsetC5x, OffsetC6x, OffsetC7x, OffsetC8x, OffsetC9x, OffsetC10x, OffsetC11x, OffsetC12x, OffsetC13x, OffsetC14x, OffsetC15x };
static const float weight[15] = { 0.0443266667, 0.0872994708, 0.0820892038, 0.0734818355, 0.0626171681, 0.0507956191, 0.0392263968, 0.0288369812, 0.0201808877, 0.0134446557, 0.0085266392, 0.0051478359, 0.0029586248, 0.0016187257, 0.0008430913 };
blur *= weight[0];
[loop]
for(int i = 1; i < 15; ++i)
{
coord = float2(offset[i],0.0);
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 4)
{
static const float offset[18] = { 0.0, OffsetD2x, OffsetD3x, OffsetD4x, OffsetD5x, OffsetD6x, OffsetD7x, OffsetD8x, OffsetD9x, OffsetD10x, OffsetD11x, OffsetD12x, OffsetD13x, OffsetD14x, OffsetD15x, OffsetD16x, OffsetD17x, OffsetD18x };
static const float weight[18] = { 0.033245, 0.0659162217, 0.0636705814, 0.0598194658, 0.0546642566, 0.0485871646, 0.0420045997, 0.0353207015, 0.0288880982, 0.0229808311, 0.0177815511, 0.013382297, 0.0097960001, 0.0069746748, 0.0048301008, 0.0032534598, 0.0021315311, 0.0013582974 };
blur *= weight[0];
[loop]
for(int i = 1; i < 18; ++i)
{
coord = float2(offset[i],0.0);
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 1)
{
static const float offset[6] = { 0.0, OffsetA2x, OffsetA3x, OffsetA4x, OffsetA5x, OffsetA6x };
static const float weight[6] = { 0.13298, 0.23227575, 0.1353261595, 0.0511557427, 0.01253922, 0.0019913644 };
blur *= weight[0];
[loop]
for(int i = 1; i < 6; ++i)
{
coord = float2(offset[i],0.0);
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
else
{
if(ClarityRadius == 0)
{
static const float offset[4] = { 0.0, Offset02x, Offset03x, Offset04x };
static const float weight[4] = { 0.39894, 0.2959599993, 0.0045656525, 0.00000149278686458842 };
blur *= weight[0];
[loop]
for(int i = 1; i < 4; ++i)
{
coord = float2(offset[i],0.0);
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord + coord, 0.0, 0.0)).CF * weight[i];
blur += tex2Dlod(Clarity2Sampler2, float4(texcoord - coord, 0.0, 0.0)).CF * weight[i];
}
}
}
}
}
}
return blur;
}
technique Clarity2
{
pass Clarity1
{
VertexShader = PostProcessVS;
PixelShader = Clarity1;
RenderTarget = Clarity2Tex;
}
pass Clarity2
{
VertexShader = PostProcessVS;
PixelShader = Clarity2;
RenderTarget = Clarity2Tex2;
}
pass Clarity3
{
VertexShader = PostProcessVS;
PixelShader = Clarity3;
RenderTarget = Clarity2Tex;
}
pass ClarityFinal
{
VertexShader = PostProcessVS;
PixelShader = ClarityFinal;
}
}
Oh, I also added a preprocessor setting for the luma mode, add Clarity_Luma=0 to the preprocessor definitions in the settings tab, you can use the values 0 through 6. I'll add some more info on what each one does at some point, but if neither of these fixes work with the default setting of 0 then try cycling through the others to see if it helps.
Please Log in or Create an account to join the conversation.
- Echo
I am getting that with both: with Clarity2 standalone and also in combination with other effects/shadersAre you getting this when only Clarity2 is running, or do you only see it in combination with other shaders?
I'll try all of them solutions later today and will keep you posted.
Please Log in or Create an account to join the conversation.
- Echo
After some intensive testing I managed to figure out what was causing the new problem that I mentioned below:
I tried both versions for a little bit and both of them do fix the issue:
08.16.17a @ Clarity_Luma=4 or 5 give the best results (better then 08.16.17b which makes the image less sharp and somewhat darker)
BUT both version cause a whole new problem: Overall brightness
No matter what Clarity_Luma is set on (0-6) it makes the image way too bright and in the few games I've tested ClarityDarkIntensity doesn't work anymore.
Such example is Deus Ex: Mankind Divided (on the Main Menu)
The brightness issue isn't effect by: MaskContrast (0 or more) or Blend-modes or any other function like ClarityLightIntensity.
I tried that with only Claritiy2 active and also with other shaders enabled, same unfortunate results.
Update 1:
1) Old Clarity2 (without other effects/shaders):
2) Clarity2 08.16.17a & 08.16.17b (without other effects/shaders):
3)Old Clarity2 (with other effects/shaders enabled):
4)Clarity2 08.16.17a & 08.16.17b (with other effects/shaders enabled):
its because I had 2 Clarity.fx's inside the shaders folders but only 1 was active at a time so that I could compare between them easier (Clarity.fx & Clarity2.fx)
Update:
I did change the "technique Clarity2" to "technique Clarity" for the previous version of Clartity2 v.1.1 and named it Clarity.fx with separated settings, but kept the new Clarity2.fx technique intact. Also it was in the same technique-sorting.
But after removing the old (not active) Clarity.fx version and reloaded Reshade 3,.0.8, it solved the brightness issue.
Comparisons:
Clarity2 version 08.16.17a is way better. Version 17b makes the image less sharper and a bit more dimmer/darker.
The best results with 17a is Clarity_Luma @ 5 but it doesn't really remove the glitching completely, It does how ever removes it completely if I change ClarityFloat sharp = saturate(1.0-blur); to ClarityFloat sharp = saturate(0.995-blur); but makes the image a little bit dimmer/darker (a higher MaskContrast fixes the dimmed/dark areas)
My settings with Clarity2 version 08.16.17a @1.0-blur & MaskContrast=0.20 & Clarity_Luma=5 (see left bottom side of the pic for the glitch):
Techniques=LumaSharpen,Clarity2,Tonemap,LiftGammaGain,Technicolor2,Vibrance,Curves,Levels2
TechniqueSorting=LumaSharpen,Clarity2,Tonemap,LiftGammaGain,Technicolor2,Vibrance,Curves,Levels2
[Clarity2.fx]
ClarityBlendMode=0.000000
ClarityRadius=2.000000
ClarityOffset=10.000000
ClarityDarkIntensity=0.750000
BlendIfRange=0.000000
ClarityBlendIfDark=0.000000
ClarityBlendIfLight=255.000000
ClarityStrength=0.750000
MaskContrast=0.200000
ClarityLightIntensity=1.500000
DitherStrength=0.000000
PreprocessorDefinitions=0.000000
DebugMode=0.000000
test=1.000000
[Vibrance.fx]
Vibrance=0.325000
VibranceRGBBalance=1.000000,1.000000,1.000000
[LumaSharpen.fx]
sharp_strength=0.400000
pattern=1.000000
sharp_clamp=0.025000
offset_bias=2.400000
show_sharpen=0.000000
[Technicolor2.fx]
Saturation=0.850000
ColorStrength=0.058824,0.058824,0.058824
Brightness=0.250000
Strength=0.850000
[Curves.fx]
Mode=2.000000
Formula=10.000000
Contrast=0.295000
[Tonemap.fx]
Defog=0.000000
Bleach=0.000000
Gamma=0.750000
Exposure=0.000000
Saturation=0.495000
FogColor=0.000000,0.000000,0.000000
[LiftGammaGain.fx]
RGB_Lift=1.075000,1.075000,1.075000
RGB_Gamma=1.305000,1.305000,1.305000
RGB_Gain=1.020000,1.020000,1.020000
[Levels2.fx]
InputBlackPoint=0.058824,0.058824,0.058824
InputWhitePoint=0.882353,0.882353,0.882353
AvoidClipping=0.000000
InputGamma=0.915000,0.915000,0.915000
ColorRangeShiftSwitch=0.000000
ColorRangeShift=0.011765,0.011765,0.011765
OutputBlackPoint=0.000000,0.000000,0.000000
HighlightClipping=0.000000
OutputWhitePoint=0.901961,0.901961,0.901961
My current settings with Clarity2 version 08.16.17a @0.995-blur & MaskContrast=0.35 & Clarity_Luma=5 :
Techniques=LumaSharpen,Clarity2,Tonemap,LiftGammaGain,Technicolor2,Vibrance,Curves,Levels2
TechniqueSorting=LumaSharpen,Clarity2,Tonemap,LiftGammaGain,Technicolor2,Vibrance,Curves,Levels2
[Clarity2.fx]
ClarityBlendMode=0.000000
ClarityRadius=2.000000
ClarityOffset=10.000000
ClarityDarkIntensity=0.750000
BlendIfRange=0.000000
ClarityBlendIfDark=0.000000
ClarityBlendIfLight=255.000000
ClarityStrength=0.750000
MaskContrast=0.350000
ClarityLightIntensity=1.500000
DitherStrength=0.000000
PreprocessorDefinitions=0.000000
DebugMode=0.000000
test=1.000000
[Vibrance.fx]
Vibrance=0.325000
VibranceRGBBalance=1.000000,1.000000,1.000000
[LumaSharpen.fx]
sharp_strength=0.400000
pattern=1.000000
sharp_clamp=0.025000
offset_bias=2.400000
show_sharpen=0.000000
[Technicolor2.fx]
Saturation=0.850000
ColorStrength=0.058824,0.058824,0.058824
Brightness=0.250000
Strength=0.850000
[Curves.fx]
Mode=2.000000
Formula=10.000000
Contrast=0.295000
[Tonemap.fx]
Defog=0.000000
Bleach=0.000000
Gamma=0.750000
Exposure=0.000000
Saturation=0.495000
FogColor=0.000000,0.000000,0.000000
[LiftGammaGain.fx]
RGB_Lift=1.075000,1.075000,1.075000
RGB_Gamma=1.305000,1.305000,1.305000
RGB_Gain=1.020000,1.020000,1.020000
[Levels2.fx]
InputBlackPoint=0.058824,0.058824,0.058824
InputWhitePoint=0.882353,0.882353,0.882353
AvoidClipping=0.000000
InputGamma=0.915000,0.915000,0.915000
ColorRangeShiftSwitch=0.000000
ColorRangeShift=0.011765,0.011765,0.011765
OutputBlackPoint=0.000000,0.000000,0.000000
HighlightClipping=0.000000
OutputWhitePoint=0.901961,0.901961,0.901961
Hope this will help with finding a solution.
Please Log in or Create an account to join the conversation.
- crosire
Not weird at all. If both fx files contain the same technique name, enabling one will enable both at the same time.Echo wrote: its because I had 2 Clarity.fx's inside the shaders folders but only 1 was active at a time so that I could compare between them easier (Clarity.fx & Clarity2.fx)
Really weird, but after removing 1 Clarity.fx and reloading Reshade 3, it solved the brightness issue.
Please Log in or Create an account to join the conversation.
- Echo
crosire wrote:
Not weird at all. If both fx files contain the same technique name, enabling one will enable both at the same time.Echo wrote: its because I had 2 Clarity.fx's inside the shaders folders but only 1 was active at a time so that I could compare between them easier (Clarity.fx & Clarity2.fx)
Really weird, but after removing 1 Clarity.fx and reloading Reshade 3, it solved the brightness issue.
Sorry forgot to mention that I did change the "technique Clarity2" to "technique Clarity" for the previous version of Clartity2 v.1.1 and named it Clarity.fx with separated settings, but kept the new Clarity2.fx technique intact. Also it was in the same technique-sorting. But like I mentioned, a single Clarity.fx was active at a time in Reshade 3.0.8.
Please Log in or Create an account to join the conversation.
- Ioxa
- Topic Author
float4 orig = tex2D(ReShade::BackBuffer, texcoord);
float4 orig = saturate(tex2D(ReShade::BackBuffer, texcoord));
I think this problem is being caused by negative values somewhere and thats the only thing I didn't clamp between 0 and 1.
Please Log in or Create an account to join the conversation.
- Echo
Ioxa wrote: I feel like this shouldn't be necessary but try changing line 278 from
tofloat4 orig = tex2D(ReShade::BackBuffer, texcoord);float4 orig = saturate(tex2D(ReShade::BackBuffer, texcoord));
I think this problem is being caused by negative values somewhere and thats the only thing I didn't clamp between 0 and 1.
I did what you asked, but I couldn't see any difference in image-quality and the glitch is still there
(@ClarityFloat sharp = saturate(1.0-blur);).
I also found another interesting bug (at least I think its a bug or maybe its what it's suppose to do) with the new Clarity_Luma settings:
Clarity_Luma=4
Clarity_Luma=6
Clarity_Luma=5 (best setting so far with ClarityFloat sharp = saturate(0.995-blur);)
Here is the RAW-PNG that you might wanna test it with:
Here is a mix of both RAW-PNG's (ME:A & intro DX:MD):
Tested with these preset-settings:
Techniques=LumaSharpen,Clarity2,Tonemap,LiftGammaGain,Technicolor2,Vibrance,Curves,Levels2
TechniqueSorting=LumaSharpen,Clarity2,Tonemap,LiftGammaGain,Technicolor2,Vibrance,Curves,Levels2
[Clarity2.fx]
ClarityBlendMode=0.000000
ClarityRadius=2.000000
ClarityOffset=10.000000
ClarityDarkIntensity=0.750000
BlendIfRange=0.000000
ClarityBlendIfDark=0.000000
ClarityBlendIfLight=255.000000
ClarityStrength=0.750000
MaskContrast=0.200000
ClarityLightIntensity=1.500000
DitherStrength=0.000000
PreprocessorDefinitions=0.000000
DebugMode=0.000000
test=1.000000
[Vibrance.fx]
Vibrance=0.325000
VibranceRGBBalance=1.000000,1.000000,1.000000
[LumaSharpen.fx]
sharp_strength=0.400000
pattern=1.000000
sharp_clamp=0.025000
offset_bias=2.400000
show_sharpen=0.000000
[Technicolor2.fx]
Saturation=0.850000
ColorStrength=0.058824,0.058824,0.058824
Brightness=0.250000
Strength=0.850000
[Curves.fx]
Mode=2.000000
Formula=10.000000
Contrast=0.295000
[Tonemap.fx]
Defog=0.000000
Bleach=0.000000
Gamma=0.750000
Exposure=0.000000
Saturation=0.495000
FogColor=0.000000,0.000000,0.000000
[LiftGammaGain.fx]
RGB_Lift=1.075000,1.075000,1.075000
RGB_Gamma=1.305000,1.305000,1.305000
RGB_Gain=1.020000,1.020000,1.020000
[Levels2.fx]
InputBlackPoint=0.058824,0.058824,0.058824
InputWhitePoint=0.882353,0.882353,0.882353
AvoidClipping=0.000000
InputGamma=0.915000,0.915000,0.915000
ColorRangeShiftSwitch=0.000000
ColorRangeShift=0.011765,0.011765,0.011765
OutputBlackPoint=0.000000,0.000000,0.000000
HighlightClipping=0.000000
OutputWhitePoint=0.901961,0.901961,0.901961
Please Log in or Create an account to join the conversation.
- Ioxa
- Topic Author
Thanks for testing this and posting those .pngs. Hopefully I'll be able to find a fix soon.
Please Log in or Create an account to join the conversation.
- Echo
Ioxa wrote: Strange... I'm able to duplicate it though so I'll probably just start rebuilding the shader line by line and see where the problem shows up. I'm also getting some weirdness when using RGB mode and the hard light blend mode so it seems like there may be a few problems here.
Thanks for testing this and posting those .pngs. Hopefully I'll be able to find a fix soon.
No problem at all! I am glad to be able to help you with finding a better solution then mine.
Please Log in or Create an account to join the conversation.
- Marty
The problem is almost certainly the LUT shader. If the LUT isn't the default size , that is 32x32, it won't work correctly. Changing the lutsize and lutamount values in shader itself and adding the values in pre-processor produces the green tint I was talking about.
Plus the fLUT_TileSizeXY= and fLUT_TileAmount= are swaped, meaning the TileAmount is the TileSize and vice versa.
It may not be the right thread to discuss this, but it would be nice to have fully working LUT shader...
The LUT itself must be OK, I made it exactly the same as the 32x32 working one.
EDIT:
I tried to load LUT without any changes, to test this. There is the lut I loaded and at the bottom is the lut of how it actually looks. There must be something wrong...
Please Log in or Create an account to join the conversation.
- Chavolatra
Please Log in or Create an account to join the conversation.