aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/out/gl_video_shaders.glsl
diff options
context:
space:
mode:
authorGravatar Niklas Haas <git@nand.wakku.to>2015-01-18 18:57:12 +0100
committerGravatar Niklas Haas <git@nand.wakku.to>2015-01-22 19:39:58 +0100
commit2d182fdea0a068cbbbe88b575963cbb480444f31 (patch)
tree407176b7db120a82106ccb05dbdce06917c635f8 /video/out/gl_video_shaders.glsl
parent6c250505fedc54a3918788f70445f5fff9d2569a (diff)
vo_opengl: implement naive anti-ringing
This is not quite the same thing as madVR's antiringing algorithm, but it essentially does something similar. Porting madVR's approach to elliptic coordinates will take some amount of thought.
Diffstat (limited to 'video/out/gl_video_shaders.glsl')
-rw-r--r--video/out/gl_video_shaders.glsl23
1 files changed, 17 insertions, 6 deletions
diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl
index fa9bfa2e95..d3cbbb7c41 100644
--- a/video/out/gl_video_shaders.glsl
+++ b/video/out/gl_video_shaders.glsl
@@ -188,6 +188,7 @@ uniform float dither_quantization;
uniform float dither_center;
uniform float filter_param1_l;
uniform float filter_param1_c;
+uniform float antiring_factor;
uniform vec2 dither_size;
in vec2 texcoord;
@@ -298,21 +299,31 @@ float[6] weights6(sampler2D lookup, float f) {
return res; \
}
-#define SAMPLE_POLAR(LUT, R, X, Y) \
+#define SAMPLE_POLAR_HELPER(LUT, R, X, Y) \
w = texture1D(LUT, length(vec2(X, Y) - fcoord)/R).r; \
+ c = texture(tex, base + pt * vec2(X, Y)); \
wsum += w; \
- res += w * texture(tex, base + pt * vec2(X, Y)); \
+ res += w * c; \
-#define SAMPLE_CONVOLUTION_POLAR_R(NAME, R, LUT, WEIGHTS_FN) \
+#define SAMPLE_POLAR_PRIMARY(LUT, R, X, Y) \
+ SAMPLE_POLAR_HELPER(LUT, R, X, Y) \
+ lo = min(lo, c); \
+ hi = max(hi, c); \
+
+#define SAMPLE_CONVOLUTION_POLAR_R(NAME, R, LUT, WEIGHTS_FN, ANTIRING) \
vec4 NAME(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) { \
vec2 pt = vec2(1.0) / texsize; \
vec2 fcoord = fract(texcoord * texsize - vec2(0.5)); \
vec2 base = texcoord - fcoord * pt; \
- vec4 res = vec4(0); \
- float wsum = 0; \
+ vec4 res = vec4(0.0); \
+ vec4 lo = vec4(1.0); \
+ vec4 hi = vec4(0.0); \
+ float wsum = 0.0; \
float w; \
+ vec4 c; \
WEIGHTS_FN(LUT); \
- return res / wsum; \
+ res /= wsum; \
+ return mix(res, clamp(res, lo, hi), ANTIRING); \
}
#ifdef DEF_SCALER0