From 041bfdfd5522923fcb5edb361a93587baf36ee82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Theo=20M=C3=BCller?= Date: Fri, 1 Feb 2019 20:19:15 +0100 Subject: [PATCH] Make anti-aliasing work with invert --- shaders/graph/1.frag | 6 ++---- shaders/graph/4.frag | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 shaders/graph/4.frag diff --git a/shaders/graph/1.frag b/shaders/graph/1.frag index 9b82d05..b52423f 100644 --- a/shaders/graph/1.frag +++ b/shaders/graph/1.frag @@ -107,11 +107,9 @@ void render_side(in sampler1D tex, float idx) { float s = get_line_height(tex, idx); /* and finally set fragment color if we are in range */ - #if INVERT > 0 - float pos = float(screen.y) - gl_FragCoord.y; - #else + float pos = gl_FragCoord.y; - #endif + if (pos + 1.5 <= s) { fragment = COLOR; } else { diff --git a/shaders/graph/4.frag b/shaders/graph/4.frag new file mode 100644 index 0000000..4630153 --- /dev/null +++ b/shaders/graph/4.frag @@ -0,0 +1,22 @@ + +in vec4 gl_FragCoord; + +#request uniform "screen" screen +uniform ivec2 screen; /* screen dimensions */ + +#request uniform "prev" tex +uniform sampler2D tex; /* screen texture */ + +out vec4 fragment; /* output */ + +#include "@graph.glsl" +#include ":graph.glsl" + +void main() { + float newy = gl_FragCoord.y; + #if INVERT > 0 + newy = float(screen.y + 1) - newy; + #endif + + fragment = texelFetch(tex, ivec2(gl_FragCoord.x, newy), 0); +}