LibGDX - pixel not perfect when screen scaled

Before I start, my first language isn’t English. So I may have issues with grammars or words.

I’m currently making pixel game and there is problem with scaling screen.
LibGDX’s OrthographicCamera is what I used for scaling screen.
Texture is used for spritesheet and PolygonSpriteBatch.draw() is used to draw on screen
Image should be 3 times bigger than original spritesheet, So I changed OrthographicCamera’s Zoom to 1/3.

(This image isn’t screenshot of what happened It’s custom drawn for explanation)
Red rectangle indicates source position used and Blue rectangle indicates problem.
Left one is spritesheet and Right one is image displayed on Screen.

Upper Image shows scaling affecting source position. When I saw this error I thought i set sourceX wrong but it wasn’t.
Only 1/3 of pixel from the sourceImage that shouldn’t be there is added on screen.
Batch’s draw method get source positions with Integer, and also It doesn’t happen when it’s not scaled

Black Rectangle shows distortion happen when scaling.
Image itself is not scaled correctly and partly distorted

These errors do not ‘always’ happen. Sometime Image is displayed correctly but sometime doesn’t.
Moving camera makes both error to settle or error to occur.
So I assume error happens only when camera is at certain Position?

So my question is, as I need to draw PixelPerfect scaled Screen, how do I resolve these errors?

I use:

and after producing atlas, I use it like this: (Scala lang)


val atlas: TextureAtlas = new TextureAtlas(Gdx.files.internal("atlas/all.atlas"))
val sprite = atlas.createSprite(key)

//...
//some sprite transformations

sprite.setScale(proto.scale._1, proto.scale._2)
sprite.setRotation(proto.rotation)
sprite.setFlip(proto.flip._1, proto.flip._2)
//...
//draw sprite on batchsprite
sprite.draw(batch)

All along with camera zoom etc. It works fine. Maybe it would be better? It looks like you are implementing your own atlas (?)


About your specific problem with these pixels- hard to say. Maybe it's texture filtering problem? Try use other texture filter. [quote] //like this: myTexture.setFilter(Textue.TextureFilter.Linear, Textue.TextureFilter.Linear); //available filtering from libgdx source code:: public enum TextureFilter { Nearest(GL20.GL_NEAREST), Linear(GL20.GL_LINEAR), MipMap(GL20.GL_LINEAR_MIPMAP_LINEAR), MipMapNearestNearest( GL20.GL_NEAREST_MIPMAP_NEAREST), MipMapLinearNearest(GL20.GL_LINEAR_MIPMAP_NEAREST), MipMapNearestLinear( GL20.GL_NEAREST_MIPMAP_LINEAR), MipMapLinearLinear(GL20.GL_LINEAR_MIPMAP_LINEAR); //... [/quote]

Thanks for your answer.
But I tried Linear filter but it makes image blurred and also problems wert still there.
I also tried all other filters but It doesn’t solved the problem.