When creating a game on LibGDX in pixel design, I encountered artifacts in the entire image. Artifacts appear on the places where there is a change of color, and only on Android. On Windows, everything draws well. Screenshot on Android

Nearest texture filtering. If you make Linear, the image becomes slightly soapy, which I do not need. Of course, the picture stretches a bit on Android.

Textures are loaded via TextureAtlas. I bring to the screen TextureRegion via SpriteBatch. The picture on the screen does not move anywhere.

Some files and texture atlas from the game: https://yadi.sk/d/34b5Bp6ysvcyq Part of the code from the class inherited from the Game:

static final float GAME_WIDTH = 640.0f; static final float GAME_HEIGHT = 360.0f; float screenWidth = Gdx.graphics.getWidth(); float screenHeight = Gdx.graphics.getHeight(); Gdx.app.log("Width", screenWidth + " "); Gdx.app.log("Height", screenHeight + " "); scale = GAME_WIDTH / screenWidth; Gdx.app.log("Scale", scale + " "); gameWidth = GAME_WIDTH; gameHeight = screenHeight * scale; cam = new OrthographicCamera(); cam.setToOrtho(true, gameWidth, gameHeight); delta_cam = (GAME_WIDTH - GAME_HEIGHT) / 2; delta_ass = (gameWidth - gameHeight) / 2; delta_scr = delta_cam - delta_ass; Assets.load((int) delta_ass, (int) gameHeight, (int) gameWidth); Settings.load(); batch = new SpriteBatch(); batch.setProjectionMatrix(cam.combined); 
  • They wrote very superficially, there is no code, it is difficult to solve the problem. Even at least where the artifact ... And finally, artifacts can appear in the absence of synchronization vertical vsync. I think what I mean. - Denis Kotlyarov
  • @DenisKotlyarov vsync does not matter here, because picture is not moving. Artifacts under each letter, and not even the background can be seen. Image drawing via SpriteBatch. - Zakoulov
  • one
    Add the original texture to the question, it will be extremely useful - Unick
  • @Unick added textures. If you need any other files, tell me. - Zakoulov

2 answers 2

It looks like dithering - attempts to rasterize taking into account the partial overlap of pixels.

Check that you have everything pixel-by-pixel in the coordinates of all the sprites verified and all sizes are the same. For example - that the sprite 12 * 16 is drawn exactly at 60 * 80, and not 60.125 * 80.2375.

PS It is embarrassing that in the right stick of the letter P the width changes by one pixel, as if some bevel is coming. Understanding what's the matter without knowing your drawing process is impossible.

  • I am using libGDX for rendering. The texture is really marssed, and such artifacts are obtained. How can you change the rasterization process so that the pixels are drawn in the closest position to them? - Zakoulov

I do not know how it works .. but I increased the size of the game screen by 0.1:

 static final float GAME_WIDTH = 640.1f; static final float GAME_HEIGHT = 360.1f; 

And on the phone all such artifacts disappeared. crutch of the year