- Home /
Strange Antialiasing in simple 2d square sprite
I'm making a simple clone tetris and I'm seeing a strange artifact as the blocks move across the screen, this gif shows it quite well:
The image for my Block sprite (of which this piece contains 4) is below, I've tried making different sizes of the image. I've also tried frobbing basically every setting I can find including the rendering settings for the project but nothing seems to help (I am admittedly quite inexperienced). Any suggestions would be greatly appreciated.
Answer by Namey5 · Apr 25, 2020 at 07:07 AM
The way objects are rendered is by taking infinitely small samples at the centre of each pixel and assuming that that sample is a good approximation for the entire pixel. Unfortunately, you do get cases like this - where something should only be a pixel in dimensions, but ends up in the sample range of two pixels and is stretched. Pixel snapping is the solution Unity have for this - wherein the whole object is snapped to a pixel grid such that there shouldn't be any incorrect subpixel samples;
https://docs.unity3d.com/Packages/com.unity.2d.pixel-perfect@1.0/manual/index.html
This should be a setting in the sprite renderer, although I am unsure as to whether you need to instal the above package or not for it to be available.
Answer by AdamBarnett · Apr 25, 2020 at 06:21 PM
Thanks so much for the reply. It looks as though that was my issue. For anyone who stumbles on this later I found this guide very helpful https://hackernoon.com/making-your-pixel-art-game-look-pixel-perfect-in-unity3d-3534963cad1d I'd also add I found the pixel perfect camera component very difficult to work with so a solution that also worked in this case was that I'd accidentally set the sprite filter mode property to point (which is needed for nice crisp edges, but which for my case was making things seem far worse and setting this back to Bilinear was also acceptable).