I am rendering pixelart with manual filtering (https://csantosbh.wordpress.com/2014/01/25/manual-texture-filtering-for-pixelated-games-in-webgl/) in multiple render passes to layer it, but i am getting these grey lines around the edges. I thought the issue was not using premultiplied alpha but i tried doing, solving the lines when they happened within one render pass, like the layers of my parallax background, but they persist between the different render passes.
What I tried so far:
· rendering each pass to a separate texture in an array texture and then manually blending them together.
· rendering each layer to the same texture first and then to the framebuffer, which results in white outlines (see pic 2)
this is the code i used for manual blending
@fs fs_display
layout(binding=0) uniform texture2DArray tex0;
layout(binding=0) uniform sampler smp0;
in vec2 uv;
flat in int id;
out vec4 frag_color;
vec4 blend2(vec4 dst, vec4 src) {
float final_alpha = src.a + dst.a * (1.0 - src.a);
vec3 a = src.rgb * src.a + dst.rgb * dst.a * (1.0-src.a);
if (final_alpha == 0.0) {
a = vec3(0, 0, 0);
} else {
a = a / final_alpha;
}
return vec4(a, final_alpha);
}
void main() {
vec4 c0 = texture(sampler2DArray(tex0, smp0), vec3(uv, 0));
vec4 c1 = texture(sampler2DArray(tex0, smp0), vec3(uv, 1));
vec4 c2 = texture(sampler2DArray(tex0, smp0), vec3(uv, 2));
vec4 c3 = texture(sampler2DArray(tex0, smp0), vec3(uv, 3));
// c1 = blend(c0, c1);
// c2 = blend(c1, c2);
// c3 = blend(c2, c3);
// frag_color = c3;
c2 = blend2(c2, c3);
c1 = blend2(c1, c2);
c0 = blend2(c0, c1);
frag_color = c0;
}
@end