mirror of
https://github.com/cemu-project/cemu_graphic_packs.git
synced 2024-11-26 19:44:14 +01:00
ClarityGFX
Reversion tell I can fix a few bugs that break the shader.
This commit is contained in:
parent
ac68d54e4a
commit
2591dfd3ef
@ -22,76 +22,25 @@
|
||||
|
||||
//##########################################################
|
||||
|
||||
//Don't touch.
|
||||
|
||||
highp const float floor = 0.0 / 255;
|
||||
highp const float scale = 255.0/(255.0-0.0);
|
||||
precision highp float;
|
||||
|
||||
//Don't touch.
|
||||
|
||||
//-----------------------------------------------------------
|
||||
|
||||
//Adjustable Values:
|
||||
|
||||
lowp uniform float brightness = 1.15; // [0.0 ~ 2.0] [1.0 Default] [1.15 Clarity]
|
||||
lowp uniform float contrast; // Blank=Neutral [0.1 ~ 2.0] Contrast Adjustment
|
||||
|
||||
lowp uniform float saturation; // Blank=Neutral [-1.0 ~ 1.0] Color Saturation Adjustment.
|
||||
lowp uniform float alpha = 1.0; // [Don't touch this.]
|
||||
|
||||
lowp const float gamma = 1.50; // [1.0 Default] [1.43 Serfrost] [1.50 Jamie]
|
||||
const float exposure = 0.00; // [-1.0 ~ 1.0] Light exposure Adjustment.
|
||||
|
||||
const float defog = 0.12; // [0.0 ~ 1.0] How much of the far distance fog to "remove."
|
||||
|
||||
//-----------------------------------------------------------
|
||||
|
||||
// Contrast, saturation, brightness
|
||||
// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
|
||||
|
||||
#define GammaCorrection(color, gamma) pow(color, 1.0 / gamma)
|
||||
vec3 ContrastSaturationBrightness(vec3 color, float brt, float sat, float con)
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------
|
||||
|
||||
// Increase or decrease theese values to adjust r, g and b color channels seperately
|
||||
// Coeff requires Photoshop values.
|
||||
|
||||
const float AvgLumR = 0.5;
|
||||
const float AvgLumG = 0.5;
|
||||
const float AvgLumB = 0.5;
|
||||
|
||||
const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
|
||||
// Adjustable values:
|
||||
precision lowp float;
|
||||
const float fogfactor = 0.4; // [1.0 Default] Changes amount of fog
|
||||
const float brightness = 1.2; // [1.0 Default] Lighten or Darken Shadows
|
||||
const float Gamma = 1.5; // [1.0 Default] [2.0 Clarity]
|
||||
const float contrast = 1.5;
|
||||
const float Saturation = 0.10; // [-1.0, 1.0] Saturates Colors
|
||||
const float Exposure = 0.00; // [-1.0, 1.0] Exposure Adjustment
|
||||
const float Defog = 0.12; // [0.0, 1.0] How much of the far distance fog to "remove."
|
||||
|
||||
//End of adjustable values
|
||||
|
||||
//###########################################################
|
||||
|
||||
//Do not edit below this line.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);
|
||||
vec3 brtColor = color * brt;
|
||||
float intensityf = dot(brtColor, LumCoeff);
|
||||
vec3 intensity = vec3(intensityf, intensityf, intensityf);
|
||||
vec3 satColor = mix(intensity, brtColor, sat);
|
||||
vec3 conColor = mix(AvgLumin, satColor, con);
|
||||
color.rgb = conColor;
|
||||
return color;
|
||||
}
|
||||
|
||||
const float floor = 0.0 / 255;
|
||||
const float scale = 255.0/(255.0-0.0);
|
||||
const float Bleach = 0.0;
|
||||
const vec3 FogColor = vec3(0.0, 0.0, 0.0); //defog Color";
|
||||
const vec3 FogColor = vec3(0.0, 0.0, 0.0); //Defog Color";
|
||||
|
||||
uniform ivec4 uf_remappedPS[1];
|
||||
layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf46ac800 res 320x180x1 dim 1 tm: 4 format 0816 compSel: 0 1 2 5 mipView: 0x0 (num 0x5) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 1
|
||||
@ -109,15 +58,15 @@ return floatBitsToInt(clamp(intBitsToFloat(v), 0.0, 1.0));
|
||||
}
|
||||
float mul_nonIEEE(float a, float b){ if( a == 0.0 || b == 0.0 ) return 0.0; return a*b; }
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Based on CeeJay.dk's original GLSL/HLSL.
|
||||
//-----------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Tonemap version 1.1
|
||||
*
|
||||
*/
|
||||
vec3 TonemapPass(vec3 inputColor) {
|
||||
vec3 color = inputColor;
|
||||
color = clamp(color - defog * FogColor * 2.55, 0.0, 1.0); // defog
|
||||
color *= pow(2.0f, exposure); // exposure
|
||||
color = pow(color, vec3(gamma)); // Gamma
|
||||
color = clamp(color - Defog * FogColor * 2.55, 0.0, 1.0); // Defog
|
||||
color *= pow(2.0f, Exposure); // Exposure
|
||||
color = pow(color, vec3(Gamma)); // Gamma
|
||||
|
||||
const vec3 coefLuma = vec3(0.2126, 0.7152, 0.0722);
|
||||
float lum = dot(coefLuma, color);
|
||||
@ -134,61 +83,11 @@ vec3 TonemapPass(vec3 inputColor) {
|
||||
|
||||
vec3 middlegray = vec3(dot(color, vec3(1.0 / 3.0)));
|
||||
vec3 diffcolor = color - middlegray;
|
||||
color = (color + diffcolor * saturation) / (1 + (diffcolor * saturation)); // saturation
|
||||
color = (color + diffcolor * Saturation) / (1 + (diffcolor * Saturation)); // Saturation
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
// -- 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);
|
||||
@ -209,6 +108,7 @@ vec3 cubeMapSTM;
|
||||
int cubeMapFaceId;
|
||||
R0f = passParameterSem0;
|
||||
R1f.xyz = (texture(textureUnitPS0, R0f.xy).xyz);
|
||||
R1f *= fogfactor;
|
||||
R0f.xyz = (texture(textureUnitPS1, R0f.xy).xyz);
|
||||
// 0
|
||||
R126f.x = R1f.x + R0f.x;
|
||||
@ -301,9 +201,24 @@ PV1f.w = R123f.w;
|
||||
R0f.x = (mul_nonIEEE(R126f.x,R125f.w) + PV1f.w);
|
||||
R0f.y = (mul_nonIEEE(R126f.x,R127f.z) + PV1f.w);
|
||||
R0f.z = (mul_nonIEEE(R126f.x,R126f.y) + PV1f.w);
|
||||
// export
|
||||
passPixelColor0 = vec4(R0f.x, R0f.y, R0f.z, R0f.w);
|
||||
vec3 color = (passPixelColor0.xyz);
|
||||
color = TonemapPass(color);
|
||||
color = (color.xyz - floor) * scale;
|
||||
passPixelColor0 = vec4(color.x, color.y, color.z, R0f.w);
|
||||
|
||||
//Color
|
||||
vec3 fColour = (passPixelColor0.xyz);
|
||||
fColour = TonemapPass(fColour);
|
||||
vec3 gamma = vec3(1.0/2.2f, 1.0/2.2f, 1.0/2.2f);
|
||||
gamma = pow(fColour, gamma);
|
||||
float luminance = fColour.r*0.299 + fColour.g*0.587 + fColour.b*0.114;
|
||||
vec3 bright = fColour + vec3(brightness,brightness,brightness);
|
||||
vec3 contrasted = (fColour - 0.5) * contrast + 0.5;
|
||||
float mn = min(min(fColour.r, fColour.g), fColour.b);
|
||||
float mx = max(max(fColour.r, fColour.g), fColour.b);
|
||||
float sat = (1.0-(mx - mn)) * (1.0-mx) * luminance * 5.0;
|
||||
vec3 lightness = vec3((mn + mx)/2.0);
|
||||
const vec3 lightPos = vec3(0.5, 0.5, 5.0);
|
||||
const vec3 diffColour = vec3(1.0, 1.0, 1.0);
|
||||
const vec3 ambColour = vec3(0.2, 0.2, 0.2);
|
||||
fColour = (fColour.xyz - floor) * scale;
|
||||
passPixelColor0 = vec4(fColour.x, fColour.y, fColour.z, R0f.w);
|
||||
}
|
Loading…
Reference in New Issue
Block a user