Fix inverting in antialias pass
This commit is contained in:
@@ -107,9 +107,11 @@ 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 {
|
||||
|
||||
@@ -12,28 +12,52 @@ out vec4 fragment; /* output */
|
||||
#include "@graph.glsl"
|
||||
#include ":graph.glsl"
|
||||
|
||||
/* Moves toward the border of the graph, gives the
|
||||
y coordinate of the last colored pixel */
|
||||
float get_col_height_up(float x, float oy) {
|
||||
float y = oy;
|
||||
#if INVERT > 0
|
||||
while (y >= 0) {
|
||||
#else
|
||||
while (y < screen.y) {
|
||||
#endif
|
||||
vec4 f = texelFetch(tex, ivec2(x, y), 0);
|
||||
if (f.a <= 0) {
|
||||
#if INVERT > 0
|
||||
y += 1;
|
||||
#else
|
||||
y -= 1;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#if INVERT > 0
|
||||
y -= 1;
|
||||
#else
|
||||
y += 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
/* Moves toward the base of the graph, gives the
|
||||
y coordinate of the first colored pixel */
|
||||
float get_col_height_down(float x, float oy) {
|
||||
float y = oy;
|
||||
#if INVERT > 0
|
||||
while (y < screen.y) {
|
||||
#else
|
||||
while (y >= 0) {
|
||||
#endif
|
||||
vec4 f = texelFetch(tex, ivec2(x, y), 0);
|
||||
if (f.a > 0) {
|
||||
break;
|
||||
}
|
||||
#if INVERT > 0
|
||||
y += 1;
|
||||
#else
|
||||
y -= 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
return y;
|
||||
@@ -54,7 +78,7 @@ void main() {
|
||||
h2 = get_col_height_down(gl_FragCoord.x, gl_FragCoord.y);
|
||||
fragment = texelFetch(tex, ivec2(gl_FragCoord.x, h2), 0);
|
||||
|
||||
a_fact = clamp((h1 - gl_FragCoord.y) / abs(h2 - h1), 0.0, 1.0);
|
||||
a_fact = clamp(abs((h1 - gl_FragCoord.y) / (h2 - h1)), 0.0, 1.0);
|
||||
|
||||
left_done = true;
|
||||
}
|
||||
@@ -65,9 +89,9 @@ void main() {
|
||||
}
|
||||
float h3 = get_col_height_up(gl_FragCoord.x + 1, gl_FragCoord.y);
|
||||
|
||||
a_fact = max(a_fact, clamp((h3 - gl_FragCoord.y) / abs(h2 - h3), 0.0, 1.0));
|
||||
a_fact = max(a_fact, clamp(abs((h3 - gl_FragCoord.y) / (h2 - h3)), 0.0, 1.0));
|
||||
}
|
||||
|
||||
|
||||
fragment.a *= a_fact;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user