Sprite White Edges and Halos: Causes and Fixes for Godot and Unity
· 9 min read · Loopixel team
Engine options checked against the official docs; problem versions in the figures are simulated
The sprite looked clean on a transparent canvas. In the engine there is a thin white line around it, or a dark one, or a faint coloured rim that changes with the background. The art is not wrong: the edge pixels hold colour that does not belong to the character, and filtering, scaling or alpha handling in the engine makes that colour visible. This guide shows where the rim comes from, how to tell which kind you have in under a minute, and the exact settings for Godot 4, Unity and Aseprite.
On this page · 7
Where the rim comes from
A pixel in a PNG has a colour (red, green, blue) and an opacity (alpha). In a soft-edged sprite, the pixels on the outline have an alpha between 0 and 255. When the file was made, those pixels were blended with whatever was behind the character: often a white or black canvas, or the colour left over in a “transparent” area. The engine draws the pixel with the remembered colour at partial opacity. On a background that matches that colour you see nothing; on any other background you see a rim.
Five things make it worse, and they often stack:
| Cause | What happens | How it looks |
|---|---|---|
| Anti-aliased edge (alpha 1–254) | Outline pixels are half transparent and blended with the old background | Rim in the old background colour |
| Colour under transparency | Fully transparent pixels hold white or black. Filtering mixes that colour into neighbours | White or dark halo, even on a hard edge |
| Bilinear filtering | The GPU averages the colour and the alpha of the nearest four pixels | A soft 1 px band around the sprite |
| Mipmaps | Smaller copies of the texture are built by the same averaging | Rim gets thicker when the sprite is drawn smaller |
| Straight vs premultiplied alpha | A texture is treated as one kind but stored as the other | Dark or bright outline on every edge |

Tell which kind you have
- Place the sprite on three backgrounds: white, black and a saturated colour (the engine’s clear colour works). A rim that changes colour with the background is a semi-transparent edge. A rim that is the same on all three is something else, such as a drawn outline.
- Zoom in with the Nearest or Point filter. If the rim vanishes, the cause was filtering mixing colour from transparent neighbours.
- Open the PNG in an editor and read the alpha of one edge pixel. Anything between 1 and 254 is a soft edge. In an engine this is the same question as “does the rim move when I change the filter or scale?”.
- Scale the sprite up and down in the scene. If the rim gets thicker when the sprite is small, mipmaps are on.

Fix it in Godot 4
- Set the texture filter to
Nearest:Project Settings > Rendering > Textures > Canvas Textures > Default Texture Filter, or per node underCanvasItem > Texture > Filter. Godot describes Nearest as reading from the nearest pixel only, so no colour is mixed in from transparent neighbours. - Select the PNG in the FileSystem dock and open the Import dock. Keep
Process > Fix Alpha Borderon. It is on by default and puts pixels of the same surrounding colour in the transition from transparent to opaque areas, which the docs say helps with the outline effect when textures are drawn with bilinear filtering. - Leave
Mipmaps > Generateoff for 2D pixel art. Godot’s 2D defaults are no mipmaps and Lossless compression. If a texture is detected as used in 3D, Godot turns mipmaps on and changes compression, so check the Import dock if a sprite gets worse after reimport. - Only use
Process > Premult Alphaif you know you need it. The docs say a premultiplied texture needs aCanvasItemMaterialwith thePremul Alphablend mode on the nodes that use it, otherwise it draws wrong. - Click
Reimport, then check the sprite on a white, a black and a coloured background again.
If the filter is Nearest and the rim is still there, the PNG itself has semi-transparent edge pixels. Jump to repair an existing PNG. Blur and shimmer are a different symptom with a different cause; see the blurry pixel art guide.
Fix it in Unity
- Select the PNG. For a sprite sheet set
Texture TypetoSprite (2D and UI),Filter ModetoPoint (no filter), andCompressiontoNone(the 2D Pixel Perfect package documentation asks for this). - Turn mipmaps off. The Sprite reference calls the option
Generate Mipmap; older versions label it Generate Mip Maps. - Look for
Alpha is Transparencyin the texture’s import settings. Unity describes it as dilating the colour channels, which helps avoid filtering artifacts on the edges of the alpha channel when alpha represents transparency. It is documented on the Default texture type; on a Sprite texture, check whether your Unity version shows it, and if not rely on Point filtering and a clean PNG. - Click
Apply, then test on a light and a dark background.
| Check | Godot 4 | Unity |
|---|---|---|
| Filter | Nearest | Point (no filter) |
| Edge colour bleed | Process > Fix Alpha Border (on by default) | Alpha is Transparency |
| Mipmaps | Generate off | Generate Mipmap off |
| Compression | Lossless | None |
| Premultiplied alpha | Process > Premult Alpha only with a Premul Alpha material | No matching setting verified for this post; start with Point filtering and a clean PNG |
Repair an existing PNG
When the file itself has a soft edge, engine settings only hide part of it. The fix is two steps, done in an image editor or a short script:
- Make alpha hard. Pick a threshold (128 is a sensible start): every pixel at or above it becomes fully opaque, every pixel below it fully transparent. Check the silhouette; a threshold that is too low fattens the sprite, too high thins it.
- Fix the colour of the new edge. Pixels that were half transparent still carry a blended colour. Replace each one with the average colour of its fully opaque neighbours. Godot’s Fix Alpha Border and Unity’s Alpha is Transparency are the engine-side version of the same idea.

In Aseprite, working in Indexed colour mode avoids semi-transparent pixels as long as the palette colours are fully opaque: the Aseprite docs explain that transparent areas in indexed mode use one special palette index, so a pixel is either that index or a palette colour. Export with File > Export Sprite Sheet. If you resize a sprite, use a nearest-neighbour method, not a smoothing one.
Hard alpha from the start
A Loopixel sprite sheet has no semi-transparent pixels: the facts page lists alpha as hard, every pixel fully opaque or fully transparent. In the pipeline, each frame size is downscaled with area averaging and then cut at half coverage, so an edge pixel becomes solid or empty. In the sheets checked for this post, the fully transparent pixels hold black with alpha 0.
That removes the anti-aliased rim at the source. It does not make the engine settings optional: filtering still mixes the colour of neighbouring pixels, and a black colour under transparency can show as a faint dark line if you draw a Loopixel sheet with a smoothing filter. So the checklist is short: Nearest or Point filter, no mipmaps, no lossy compression. The Godot, Unity and Aseprite guides cover importing the sheet, and the slicing guide covers cell size. To preview a sheet as a transparent GIF, use sprite sheet to GIF.
Quick answers
Why is the rim white in one scene and invisible in another?
Because the rim is the old background colour at partial opacity. It disappears on a background of the same colour and shows on every other one.
Is a GIF the problem?
GIF has one transparent colour and no partial transparency, so a GIF made from a soft-edged animation either keeps a matte rim or cuts it hard. If you only see the rim in a GIF, export the animation from the PNG with a hard alpha instead of converting a flattened version.
Should I just use premultiplied alpha?
Only if your renderer and materials expect it. Per the Godot docs it needs a matching blend mode; turning it on without one creates a new rim instead of removing the old one. For pixel art, hard alpha with Nearest filtering is the simpler route.
Sources
Engine menu paths and property names above were checked against the official documentation:
- Godot: Importing images (Fix Alpha Border, Premult Alpha, Mipmaps, Lossless)
- Godot: CanvasItem (texture_filter, Nearest)
- Unity: Default texture Import Settings (Alpha is Transparency)
- Unity: Sprite (2D and UI) texture Import Settings
- Unity: 2D Pixel Perfect package
- Aseprite: Color mode
- Aseprite: Sprite sheets (Export Sprite Sheet)
Try it with one image
Upload one image and get an 8-frame pixel sprite sheet in about a minute. 1 credit per animation, credit packs from $2.99, paid once.
Create a sprite sheet