- Home /
Artifacts at Edges of Sprite
I am getting some artifacts on the edges of my 2D Sprites in both Scene and Game modes. The artifact is on the bottom of each sprite and it is a 1-pixel high row of whatever color is immediately under the sprite in the sprite sheet, and it appears and disappears when the sprite moves. For instance, if my sprite sheet had a red square and a green square on it, red on top of green, the red square would have a green artifact on the bottom.
I know what you're thinking-- just don't pack the sprites one on top of another. When I space them out more, the color of the artifact is white. I am using a .png for the sprite sheet.
Hopefully somebody out there has seen this and it is an easy fix.
You're probably not matching the size of the sprite with its showing texture. It's probably bigger than what the sprite has to offer in terms of pixels. Since the renderer tries to find the pixel that matches the size it's possible to get the one that's not within range. That's why they're packed with margin. If it's white when you put margin in, it's not using transparency, check the import settings
Answer by CodeAndWeb · Mar 07, 2018 at 01:42 PM
The issue here is that OpenGL drags in neighbor pixels...
The best way to prevent this is to add 1 row of pixels around each sprite that repeats the border pixel's color. Prevent Unity from using this extra pixel row.
An automated way of creating sprite sheets that don't have these issues is using TexturePacker.
Your answer
Follow this Question
Related Questions
2d game, sprite artifacts when moving 1 Answer
Model Cut Artifacts 0 Answers
2D Sprite, Animation Question 1 Answer
checkerboard shadows with directional lights 1 Answer
If I make a vector in Inkscape will it be a vector in unity? 1 Answer