Sign in to follow this  
Steven yeah

Black Rim around DDS format picture

Recommended Posts

I am saving my art in DDS format, using DXT1 Compression, and when i display the image on screen, there is a very obivious black line surrounding the outside of the image. (at the edge of the alpha, where the black and white meets). I tried to reduce the size of the alpha by 2 pixels and saving it, but the issue still occurs. I then tried saving in DXT3, and still it occurs, and when i save it in DXT3 and reduce the size of the alpha the problem goes away. Does anyone have the same problem, or know how to fix it, or know what causes it? Thanks.

Share this post

Link to post
Share on other sites
With DXT1, for any texels where the alpha is 0, the colour of the texel will be black. That's just the way DXT1 works (and so achieves better compression than DXT3), if alpha=1 the colour is full colour, if alpha=0 the colour is black. With DXT3, the alpha channel is stored separately, so alpha=0 pixels give you the original colour.

When a DXT1 texture gets bilinear filtered (e.g. stretched) when applied to a polygon, then the colour of a pixel will consist of the filtered average of multiple texels - if some of those texels are black (i.e. due to the way DXT1 works), then some black will bleed into the colour of that pixel.


- If your texels are mapped directly to pixels (i.e. no stretching), you shouldn't see any bleeding of the black (seethrough) texels into the coloured ones. Most people get this wrong at least once, particularly for sprites.

- DXT3 doesn't set the colour channel to black when the alpha channel is 0, so you don't get pronounced black outlines unless the colour of the alpha=~0 texels is almost black and your texture is stretched. But it does of course take more memory...

- If you use one of the pre-multiplied alpha DXT formats instead, then although the alpha=0 texels will still be black, the way the alpha=1 texels get rendered will mean you don't get the ugly black borders. Since the source is already multiplied by the SRCALPHA, you'll need to change the source blend mode of any alpha blend accordingly.

- for a stretched application of the texture, most of the black outline you see will be for pixels whose alpha is somewhere between 0 and 1 rather than precisely either. Careful use of alpha test to treat these mid-values correctly can reduce the black outlines around DXT1s significantly (even completely in some cases).

- it's common practice to make the colour of any alpha=0 (or nearly 0) texels the *same* colour as the nearest alpha=1 texel. For example, for a tree texture, although the outside of the foliage may be alpha=0, you'd still give those texels a green tree-foliage-like colour to reduce artifacts like the above.

- if this is for a non-PC MS platform, there are other platform specific tricks to reduce the outlines some more - let me know if it is.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this