This issue dates back to 13w38a.
The artifacts described here first appeared in version 1.7.3.
The bug
In the current version of bits.fsh and all previous iterations, fract and subtraction have always been used to cancel out the decimals.
vec2 oneTexel = 1.0 / InSize;
vec2 mosaicInSize = InSize / MosaicSize;
vec2 fractPix = fract(texCoord * mosaicInSize) / mosaicInSize;
vec4 baseTexel = texture(InSampler, texCoord - fractPix);But instead of fully cancelling out, it produces artifacts due to floating point inprecision.
Steps to reproduce
/posteffect add @s minecraft:creeperLook closely at some of the scaled pixels
Observed result
Thin lines in a grid-like pattern, thinner than the desired mosaic size.
Expected result
No line artifacts, but instead perfect nearest neighbor scaling.
Additional information
Instead of using fract and subtraction to cancel out the decimals, one could instead use floor to achieve the same result:
vec2 oneTexel = 1.0 / InSize;
vec2 mosaicInSize = InSize / MosaicSize;
vec2 mosaicCoord = floor(texCoord * mosaicInSize) / mosaicInSize;
vec4 baseTexel = texture(InSampler, mosaicCoord);Though I didn't look into it in detail, the next following lines may also have an issue with its use of fract:
vec3 fractTexel = baseTexel.rgb - fract(baseTexel.rgb * Resolution) / Resolution
float luma = dot(fractTexel, vec3(0.3, 0.59, 0.11))
vec3 chroma = (fractTexel - luma) * Saturation
baseTexel.rgb = luma + chroma
baseTexel.a = 1.0;Note that the last two images were made using the bits shader with a MosaicSize of 48, to make the bug more noticeable.
When filling out my report it uploaded it pre-maturly without confirmation. Here are the images referenced in the report: