diff --git a/Shaders/CRT.fsh b/Shaders/CRT.fsh index 0bc4c656..4cbab721 100644 --- a/Shaders/CRT.fsh +++ b/Shaders/CRT.fsh @@ -158,8 +158,5 @@ STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 ou ret *= output_resolution.y - pixel_position.y; } - // Gamma correction - ret = pow(ret, vec4(0.72)); - return ret; } diff --git a/Shaders/HQ2x.fsh b/Shaders/HQ2x.fsh index 2e19fa65..7ae80637 100644 --- a/Shaders/HQ2x.fsh +++ b/Shaders/HQ2x.fsh @@ -12,7 +12,7 @@ STATIC vec3 rgb_to_hq_colospace(vec4 rgb) STATIC bool is_different(vec4 a, vec4 b) { vec3 diff = abs(rgb_to_hq_colospace(a) - rgb_to_hq_colospace(b)); - return diff.x > 0.188 || diff.y > 0.027 || diff.z > 0.031; + return diff.x > 0.018 || diff.y > 0.002 || diff.z > 0.005; } #define P(m, r) ((pattern & (m)) == (r)) @@ -84,7 +84,7 @@ STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 ou return interp_3px(w4, 2.0, w0, 1.0, w3, 1.0); } if (P(0x2f,0x2f)) { - return interp_3px(w4, 1.04, w3, 1.0, w1, 1.0); + return interp_3px(w4, 4.0, w3, 1.0, w1, 1.0); } if (P(0xbf,0x37) || P(0xdb,0x13)) { return interp_3px(w4, 5.0, w1, 2.0, w3, 1.0); diff --git a/Shaders/MasterShader.fsh b/Shaders/MasterShader.fsh index 729ab5f2..a7c33db0 100644 --- a/Shaders/MasterShader.fsh +++ b/Shaders/MasterShader.fsh @@ -9,14 +9,22 @@ uniform vec2 origin; #define equal(x, y) ((x) == (y)) #define inequal(x, y) ((x) != (y)) #define STATIC +#define GAMMA (2.2) out vec4 frag_color; +vec4 _texture(sampler2D t, vec2 pos) +{ + return pow(texture(t, pos), vec4(GAMMA)); +} + +#define texture _texture + #line 1 {filter} -#define BLEND_BIAS (1.0/3.0) +#define BLEND_BIAS (2.0/5.0) #define DISABLED 0 #define SIMPLE 1 @@ -58,7 +66,7 @@ void main() break; } - frag_color = mix(scale(image, position, input_resolution, output_resolution), - scale(previous_image, position, input_resolution, output_resolution), ratio); + frag_color = pow(mix(scale(image, position, input_resolution, output_resolution), + scale(previous_image, position, input_resolution, output_resolution), ratio), vec4(1.0 / GAMMA)); } diff --git a/Shaders/MasterShader.metal b/Shaders/MasterShader.metal index a0b63935..b900176f 100644 --- a/Shaders/MasterShader.metal +++ b/Shaders/MasterShader.metal @@ -12,6 +12,7 @@ typedef texture2d sampler2D; #define equal(x, y) all((x) == (y)) #define inequal(x, y) any((x) != (y)) #define STATIC static +#define GAMMA (2.2) typedef struct { float4 position [[position]]; @@ -36,7 +37,7 @@ vertex rasterizer_data vertex_shader(uint index [[ vertex_id ]], static inline float4 texture(texture2d texture, float2 pos) { constexpr sampler texture_sampler; - return float4(texture.sample(texture_sampler, pos)); + return pow(float4(texture.sample(texture_sampler, pos)), GAMMA); } #line 1 @@ -87,7 +88,7 @@ fragment float4 fragment_shader(rasterizer_data in [[stage_in]], break; } - return mix(scale(image, in.texcoords, input_resolution, *output_resolution), - scale(previous_image, in.texcoords, input_resolution, *output_resolution), ratio); + return pow(mix(scale(image, in.texcoords, input_resolution, *output_resolution), + scale(previous_image, in.texcoords, input_resolution, *output_resolution), ratio), 1 / GAMMA); } diff --git a/Shaders/OmniScale.fsh b/Shaders/OmniScale.fsh index c76f7368..eab27ae8 100644 --- a/Shaders/OmniScale.fsh +++ b/Shaders/OmniScale.fsh @@ -19,7 +19,7 @@ STATIC vec3 rgb_to_hq_colospace(vec4 rgb) STATIC bool is_different(vec4 a, vec4 b) { vec3 diff = abs(rgb_to_hq_colospace(a) - rgb_to_hq_colospace(b)); - return diff.x > 0.125 || diff.y > 0.027 || diff.z > 0.031; + return diff.x > 0.018 || diff.y > 0.002 || diff.z > 0.005; } #define P(m, r) ((pattern & (m)) == (r))