Skip to content
Search

Arcade:EdgeArtifacts

lastmod 2023-06-02created 2023-01-146 edits

When working with images, especially images with transparency, the graphics card can produce graphical artifacts at the edges. The image may have an unwanted 'border'.

The parts at the edges of a picture where pixels seem to jump out are called edge artifacts.

Why edge artifacts appear

This happens when the edges of the image do not fall cleanly on the image.

  • Edge misalignment - Edge artifacts usually occur when the image edges do not land on exact pixel boundaries.
  • Scaling
  • Rotation
  • Improper viewport (e.g. when the window width is 800 and the viewport is set to 799 or 801)

Solution

Keep sprite sizes at a power of 2, or at least the width and height must be divisible by 2.

For pixel art style games

Using the pixelated drawing mode greatly reduces the problem.

Nearest pixel

By default, Arcade draws sprites using a filter called "Linear". If you want a pixelated look instead, you can use a different filter called "Nearest". This filter also reduces the edge artifact problem.

Enable the nearest filter by using the pixelated argument when drawing.

def on_draw(self):
    self.my_sprite_list.draw(pixelated=True)

See also

Favorite site

author Zer0 sitemap