Jump to content
  • Advertisement
Sign in to follow this  
ehmdjii

that damn old textured alpha problem....

This topic is 4309 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is there nothing we can do about it? i am talking of course about the problem when using textures with alpha channel and although i am sorting objects from back to front there might be polygons of the same object in front to back order which cause background pixels to shine through. here is a screenshot: are there maybe any tricks to avoid this problem using blending, alpha-test, depthmask? dunno....? any help is greatly appreciated!

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure what you're talking about. The only issue I see in the screenshot are some minor aliasing artifacts. If those artifacts (the white pixels around the edge of your character) are indeed your problem, then you only need to adjust the alpha mask to give a tighter fit around the source graphic. Don't use antialiasing for your source graphic unless you can provide a 100% perfect alpha mask (Photoshop can do this). Instead, use antialiasing in your alpha mask, that way the edges of your source graphic get 'smoothed' by the mask itself instead of the antialiasing.

Share this post


Link to post
Share on other sites
To overcome this problem, make the colors of your image 'bleed' outside your alpha mask, preferrably all the way to the edges. Here's a exaggerated example of what I mean.



In case of having a outline around your image, make the background the same color as the outline. Hope this helps.

Share this post


Link to post
Share on other sites
thanks guys, but that's not the problem. the texture is ok, it's bleeded and the alpha mask is ok.

the problem is, that there are pixels from the objects from behind shining through, since not all polygons are correctly drawn from back to front.

Share this post


Link to post
Share on other sites
Please, for the love of God, use premultiplied alpha!

This blog entry explains it in great detail:
http://home.comcast.net/~tom_forsyth/blog.wiki.html#%5B%5BPremultiplied%20alpha%5D%5D

Share this post


Link to post
Share on other sites
thanks IvanMilles,

yeah i have heard about premultiplied alpha and it is probably the only solution i can take. but isnt it a bit hard to implement? i use PNGs btw.

Share this post


Link to post
Share on other sites
Quote:
Original post by ehmdjii
is there nothing we can do about it?

i am talking of course about the problem when using textures with alpha channel and although i am sorting objects from back to front there might be polygons of the same object in front to back order which cause background pixels to shine through.

here is a screenshot:


are there maybe any tricks to avoid this problem using blending, alpha-test, depthmask? dunno....? any help is greatly appreciated!


Have you tried zooming into youre images to make sure there aren't any artifacts/pixels left behind in the area that's supposed to be transparent?

It's easy to miss unless you make sure background is completely solid color you want to be for the alpha.

If you edited the picture in Paint Shop Pro etc use scratch remover on the edges to smooth them out? That is only if the problem only occurs along the edges, maybe will work, maybe it won't.

Share this post


Link to post
Share on other sites
Quote:
the problem is, that there are pixels from the objects from behind shining through, since not all polygons are correctly drawn from back to front.


You are confused. The pixel artifacts you are seeing is not due to your object sorting. The pixels are due to an effect called anti-aliasing, where 'soft' (semi-transparent) pixels are inserted along the edge of a 'jagged' line/curve to give a smooth, more natural appearance. In other words, the artifacts you are seeing aren't artifacts at all (in this context), but are an actual part of your sprite image. If you don't believe me, open the image+mask in a graphic editor, and place the image over a black background - you will see the same 'artifacts'.

The reason why you see the artifacts in your scene is because the color image uses anti-aliasing along it's edges. You should only use anti-aliasing on interior parts of the image, and save edge anti-aliasing for the alpha-mask (as 'Prototype' pointed out with his example).

Perhaps you could tell us what graphic editing software you are using so we can be more specific. Or perhaps you could upload your sprite images so we can show you how it needs to be done (I'd do it myself, but I'm lazy right now).

Here's an example:

This is my sprite while I'm editing it in Photoshop:

To the untrained eye, this looks fine, though I can already see the artifacts.
(Note that in this case with this specific red bunny sprite, the standard would be to use a full red square and let the alpha-mask do the rest of the work. However, I'm trying to step through the process in the somewhat the same way you would have.)

Here is the same sprite over a white background:

Looks perfect. The average person would leave it at this.

Here is the same sprite over a black background:

Notice the artifacts that weren't visible in the previous 2 examples. The artifacts are varying levels of pink as needed to give a smooth transition from red to white. From a distance, the artifacts look white, but if you zoom in, you will see that they are actually pink. With your sprite, the artifacts look white, but are actually varying levels of grey (transition from black to white). If they were in-fact pixels from distant objects 'shining' through, then these artifacts would change color as you move objects. I'm pretty sure this is not the case.

I can fix these artifacts in a number of different ways. The quickest fix would be to scale the alpha-mask down by 1 or 2 pixels. In this case, that would cause the edges of the sprite to not be smooth at all. The best fix would be to redesign the alpha-mask so that it does exactly what I need it to do.

[Edited by - swordfish on September 29, 2006 1:45:16 PM]

Share this post


Link to post
Share on other sites
u will need to create the image better (time consuming usually)
u have to make sure the alpha channel only contains values of 1 (where u want it to appear) or otherwise 0
dont use mipmaps + itll appear correctly

Share this post


Link to post
Share on other sites
I see artifacts in first texture already. So make your textere better. Don't use any compression algoritms in your file or in drawing. Just raw data. So you get only one colour to be alpha. Ban jpg etc. format you just get yourself to trouble.
Good way to hunt mistakes is next. You got white alpha so paint it black. Next go every single side trough pixel by pixel and check if any white is left. and paint it black.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!