#version 420 #extension GL_ARB_texture_gather : enable // shader 37040a485a29d54e // This is based on the work of the following people: // Clarity GFX // Credit to Jamie for main coding. // Credit to Kiri coding & Reshade logic. // Credit to Cremtif for Help. // Credit to Serfrost for preset values. // // The idea was to modify the Clarity GFX to keep the games as close as // possible to the original, only adding lumasharpening (since Reshade has bugs with the inventory in full screen). // Enjoy! //LumaSharpening const float sharp_strength = 1.70; //[0.10 to 3.00] Strength of the sharpening Default is 0.65 const float sharp_clamp = 0.035; //[0.000 to 1.000] Limits maximum amount of sharpening a pixel recieves - Default is 0.035 //Advanced sharpening settings const float offset_bias = 1.0; //[0.0 to 6.0] Offset bias adjusts the radius of the sampling pattern. //########################################################### //Do not edit under this line. uniform ivec4 uf_remappedPS[1]; layout(binding = 0) uniform sampler2D textureUnitPS0; // Bloom layout(binding = 1) uniform sampler2D textureUnitPS1;// HDR LumaShapening. layout(location = 0) in vec4 passParameterSem0; layout(location = 0) out vec4 passPixelColor0; uniform vec2 uf_fragCoordScale; //LumaSharpening #define px (1.0/1280.0*uf_fragCoordScale.x) #define py (1.0/720.0*uf_fragCoordScale.y) #define CoefLuma vec3(0.2126, 0.7152, 0.0722) float lumasharping(sampler2D tex, vec2 pos) { vec4 colorInput = texture(tex, pos); vec3 ori = colorInput.rgb; // -- Combining the strength and luma multipliers -- vec3 sharp_strength_luma = (CoefLuma * sharp_strength); // -- Gaussian filter -- // [ .25, .50, .25] [ 1 , 2 , 1 ] // [ .50, 1, .50] = [ 2 , 4 , 2 ] // [ .25, .50, .25] [ 1 , 2 , 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 return sharp_luma; } void main() { passPixelColor0.xyz = texture(textureUnitPS1, passParameterSem0.xy).xyz; float smask = lumasharping(textureUnitPS1, passParameterSem0.xy); passPixelColor0.xyz += vec3(smask); vec3 color = (passPixelColor0.xyz); passPixelColor0 = vec4(color, passParameterSem0.w); }