It looks like semitransparent pixels are blended with while color when textures are drawn scaled. It is very noticeable and looks ugly when textures are drawn on dark background.

public class SomeScreen implements Screen {
    private TextureRegion textureRegion;

    public void show() {
        // Loading texture
        Texture texture = new Texture(Gdx.files.internal("texture.png"), true);
        // Setting filter to "linear"
        texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
        // Getting the region
        textureRegion = new TextureRegion(texture, 0, 0, 64, 64);

    public void render(float delta) {
        // Clearing screen
        Gdx.gl.glClearColor(0.09f, 0.09f, 0.09f, 1f);

        // Drawing textureRegion
        Game.instance.batch.draw(textureRegion, 100f, 100f, 256f, 256f); // Actual texture region size is 64x64px

I need to get rid of that white noise around the shape, bud don't know how.

Source image:

Source image of the shape I was trying to draw

Draw results: Expected and resulting draw results


1 Answer 1


This colour usually comes from the texture itself. When using alpha transparency, even fully transparent texels still have an RGB colour, though it's usually unseen. Because we don't see it, image editors and compression tools can be inconsistent in how they handle these areas - filling them with white, black, or streaked-out copies of adjacent texels to improve predictability for compression.

The most reliable way I've found to control this is to use TGA (Targa) files for intermediate texture storage (before converting to GPU compressed formats like DXT-5 etc. when generating an executable build). Targa files don't assume that the alpha channel is transparency, so you can export arbitrary RGBA data without a compressor second-guessing what the 0-alpha texels should look like.

If you're using Photoshop or a similar tool, you'll want to create an alpha mask from the transparency of your texture, and store it as a new alpha channel. Then go back to the RGB colour planes, and paint a border behind any transparent edges of your texture, matching the colours of adjacent texels. This way you can ensure any blending with these texels during mipmapping or texture filtering won't distort the RGB result away from the colour specified by the non-fully-transparent texels in the vicinity.

When working on the Wii, I set up a Photoshop script to automatically bleed out colours into transparent regions like this by repeatedly duplicating, blurring, and merging layers (keeping the original on top), and used that as part of my standard export flow.

Note that you can also get similar artifacts if you're using a compressed texture format like DXT-1, which supports only 1-bit transparency, using transparent black as its blending colour. That doesn't appear to be the problem you're encountering here, but this can be worked around too by treating the texture as having pre-multiplied alpha, so the dark fade at the edges gets used as the normal feathering-out of the blending equation, without doubling-up the effect.

  • \$\begingroup\$ Thanks, you saved my day! I was trying to fix this using libgdx, but the reason was hidding in the image itself. \$\endgroup\$ Commented Jul 12, 2016 at 17:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .