Unwanted artifacts in a simple pixelation shader

edited November 2013 in GLSL / Shaders

I was porting this very basic shader from Shadertoy when I ran into a weird problem.

Here is what the effect looks like on Shadertoy:

Capture d’écran 2013-12-01 à 00.33.07

And here is what I get in Processing

Capture d’écran 2013-12-01 à 00.34.04

The compression makes it harder to see the artifacts but it is these colored line in between the pixels. I remember seeing a similar problem in the PShader tutorial actually.

image pixelated can

Is this a known bug? Is there a rounding error somewhere?

I only made minimal changes to the Shadertoy code:

uniform sampler2D texture;

uniform vec2 sketchSize;

void main(void)
{
    vec2 uv = gl_FragCoord.xy / sketchSize.xy;
    vec2 divs = vec2(sketchSize.x * 20.0 / sketchSize.y, 20.0);
    uv = floor(uv * divs)/ divs;
    gl_FragColor = texture2D(texture, uv);
}
Sign In or Register to comment.