diff options
Diffstat (limited to 'video/out/gl_video_shaders.glsl')
-rw-r--r-- | video/out/gl_video_shaders.glsl | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl index a93ef9374b..55258fd252 100644 --- a/video/out/gl_video_shaders.glsl +++ b/video/out/gl_video_shaders.glsl @@ -117,6 +117,7 @@ uniform sampler2D texture1; uniform sampler2D texture2; uniform sampler2D texture3; uniform vec2 textures_size[4]; +uniform vec2 chroma_center_offset; uniform sampler1D lut_c_1d; uniform sampler1D lut_l_1d; uniform sampler2D lut_c_2d; @@ -124,10 +125,12 @@ uniform sampler2D lut_l_2d; uniform sampler3D lut_3d; uniform sampler2D dither; uniform mat4x3 colormatrix; +uniform mat2 dither_trafo; uniform vec3 inv_gamma; +uniform float input_gamma; uniform float conv_gamma; uniform float dither_quantization; -uniform float dither_multiply; +uniform float dither_center; uniform float filter_param1; uniform vec2 dither_size; @@ -151,7 +154,7 @@ vec4 calcweights(float s) { vec4 t = vec4(-0.5, 0.1666, 0.3333, -0.3333) * s + vec4(1, 0, -0.5, 0.5); t = t * s + vec4(0, 0, -0.5, 0.5); t = t * s + vec4(-0.6666, 0, 0.8333, 0.1666); - vec2 a = vec2(1 / t.z, 1 / t.w); + vec2 a = vec2(1, 1) / vec2(t.z, t.w); t.xy = t.xy * a + vec2(1, 1); t.x = t.x + s; t.y = t.y - s; @@ -322,17 +325,18 @@ vec4 sample_sharpen5(sampler2D tex, vec2 texsize, vec2 texcoord) { } void main() { + vec2 chr_texcoord = texcoord + chroma_center_offset; #ifndef USE_CONV #define USE_CONV 0 #endif #if USE_CONV == CONV_PLANAR vec3 color = vec3(SAMPLE_L(texture0, textures_size[0], texcoord).r, - SAMPLE_C(texture1, textures_size[1], texcoord).r, - SAMPLE_C(texture2, textures_size[2], texcoord).r); + SAMPLE_C(texture1, textures_size[1], chr_texcoord).r, + SAMPLE_C(texture2, textures_size[2], chr_texcoord).r); float alpha = 1.0; #elif USE_CONV == CONV_NV12 vec3 color = vec3(SAMPLE_L(texture0, textures_size[0], texcoord).r, - SAMPLE_C(texture1, textures_size[1], texcoord).rg); + SAMPLE_C(texture1, textures_size[1], chr_texcoord).rg); float alpha = 1.0; #else vec4 acolor = SAMPLE_L(texture0, textures_size[0], texcoord); @@ -354,11 +358,15 @@ void main() { // wrong for 9/10 bit input color.gb = vec2(128.0/255.0); #endif +#ifdef USE_INPUT_GAMMA + color = pow(color, vec3(input_gamma)); +#endif #ifdef USE_COLORMATRIX color = mat3(colormatrix) * color + colormatrix[3]; + color = clamp(color, 0, 1); #endif -#ifdef USE_LINEAR_CONV - color = pow(color, vec3(1.0/0.45)); +#ifdef USE_CONV_GAMMA + color = pow(color, vec3(conv_gamma)); #endif #ifdef USE_LINEAR_CONV_INV // Convert from linear RGB to gamma RGB before putting it through the 3D-LUT @@ -375,8 +383,13 @@ void main() { color.rgb = srgb_compand(color.rgb); #endif #ifdef USE_DITHER - float dither_value = texture(dither, gl_FragCoord.xy / dither_size).r; - color = floor(color * dither_multiply + dither_value ) / dither_quantization; + vec2 dither_pos = gl_FragCoord.xy / dither_size; +#ifdef USE_TEMPORAL_DITHER + dither_pos = dither_trafo * dither_pos; +#endif + float dither_value = texture(dither, dither_pos).r; + color = floor(color * dither_quantization + dither_value + dither_center) / + dither_quantization; #endif #ifdef USE_ALPHA out_color = vec4(color, alpha); |