From 221352fd6d3b380281b6a6a3fb3488d7e9b4fe53 Mon Sep 17 00:00:00 2001 From: Jamie Date: Sat, 21 Oct 2017 13:41:31 -0700 Subject: [PATCH] Clarity + Luma Clarity now with Luma Sharpen --- .../bd8bba59e2149449_00000000000003c9_ps.txt | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/Enhancement/BreathOfTheWild_ClarityGFX/bd8bba59e2149449_00000000000003c9_ps.txt b/Enhancement/BreathOfTheWild_ClarityGFX/bd8bba59e2149449_00000000000003c9_ps.txt index 6be21951..cda4cfb7 100644 --- a/Enhancement/BreathOfTheWild_ClarityGFX/bd8bba59e2149449_00000000000003c9_ps.txt +++ b/Enhancement/BreathOfTheWild_ClarityGFX/bd8bba59e2149449_00000000000003c9_ps.txt @@ -98,7 +98,67 @@ vec3 TonemapPass(vec3 inputColor) { return color; } +//----------------------------------------------------------- +// LumaSharpen 1.4.1 +// original hlsl by Christian Cann Schuldt Jensen ~ CeeJay.dk +// It blurs the original pixel with the surrounding pixels and then subtracts this blur to sharpen the image. +// It does this in luma to avoid color artifacts and allows limiting the maximum sharpning to avoid or lessen halo artifacts. +// This is similar to using Unsharp Mask in Photoshop. +//----------------------------------------------------------- +// -- Sharpening -- +#define sharp_strength 0.65 //[0.10 to 3.00] Strength of the sharpening + +#define sharp_clamp 0.035 //[0.000 to 1.000] Limits maximum amount of sharpening a pixel recieves - Default is 0.035 + +// -- Advanced sharpening settings -- + +#define offset_bias 1.0 //[0.0 to 6.0] Offset bias adjusts the radius of the sampling pattern. + //I designed the pattern for offset_bias 1.0, but feel free to experiment. + +#define CoefLuma vec3(0.2126, 0.7152, 0.0722) // BT.709 & sRBG luma coefficient (Monitors and HD Television) + +vec4 texel(sampler2D tex, vec2 pos, vec2 tex_size){ + vec4 colorInput = texture(tex, pos); + + vec3 ori = colorInput.rgb; + + // -- Combining the strength and luma multipliers -- + vec3 sharp_strength_luma = (CoefLuma * sharp_strength); //I'll be combining even more multipliers with it later on + + // -- Gaussian filter -- + // [ .25, .50, .25] [ 1 , 2 , 1 ] + // [ .50, 1, .50] = [ 2 , 4 , 2 ] + // [ .25, .50, .25] [ 1 , 2 , 1 ] + + + float px = 1.0/tex_size[0]; + float py = 1.0/tex_size[1]; + + vec3 blur_ori = texture(tex, pos + vec2(px,-py) * 0.5 * offset_bias).rgb; // South East + blur_ori += texture(tex, pos + vec2(-px,-py) * 0.5 * offset_bias).rgb; // South West + blur_ori += texture(tex, pos + vec2(px,py) * 0.5 * offset_bias).rgb; // North East + blur_ori += texture(tex, pos + vec2(-px,py) * 0.5 * offset_bias).rgb; // North West + + blur_ori *= 0.25; // ( /= 4) Divide by the number of texture fetches + + + + // -- Calculate the sharpening -- + vec3 sharp = ori - blur_ori; //Subtracting the blurred image from the original image + + // -- Adjust strength of the sharpening and clamp it-- + vec4 sharp_strength_luma_clamp = vec4(sharp_strength_luma * (0.5 / sharp_clamp),0.5); //Roll part of the clamp into the dot + + float sharp_luma = clamp((dot(vec4(sharp,1.0), sharp_strength_luma_clamp)), 0.0,1.0 ); //Calculate the luma, adjust the strength, scale up and clamp + sharp_luma = (sharp_clamp * 2.0) * sharp_luma - sharp_clamp; //scale down + + + // -- Combining the values to get the final sharpened pixel -- + + colorInput.rgb = colorInput.rgb + sharp_luma; // Add the sharpening to the input color. + return clamp(colorInput, 0.0,1.0); +} void main() { vec4 R0f = vec4(0.0); @@ -216,4 +276,4 @@ vec3 color = (passPixelColor0.xyz); color = TonemapPass(color); color = (color.xyz - floor) * scale; passPixelColor0 = vec4(color.x, color.y, color.z, R0f.w); -} +} \ No newline at end of file