Skip to main content
gamedev.net
🔒 Locked

GL_LINEAR

Started by Kitasia Sep 27, 2005 at 10:47 PM 2 replies 1.2k views
Original Post
Kitasia
Kitasia
Is there a way to use GL_LINEAR with sprites that have a color key? I get a cyan ring around all my sprites.
kburkhart84
kburkhart84
I don't think so. I think you'll have to avoid GL_LINEAR because it also filters the Alpha channel. Try using GL_NEAREST and use an appropritely sized texture. If you use a texture that will be on the screen about the same number of pixels as in the texture file, the nearest filter will work fine.


Kitasia
Kitasia
Yeah, I knew nearest worked fine but linear was just soo much better looking. Ah well, thanks for the info!
Brother Bob
Brother Bob
The cyan ring around your sprite is because your color key is cyan. So replace that color with the color of the surrounding sprite.

I'm assuming you do the standard method of creating the alpha channel at run time based on the color of the pixels. Don't copy the color unconditionally. If the current pixel is opaque (don't match the color key), just copy it as usual. If the current pixel is transparent (matches the color key), and at least one of it's neighbours are opaque, set the color to the color of the sprite, not the color key. The color of the sprite can, for example, be the average of the opaque neighbours.

With this method, the ring will be the same color as the sprite, and will not be visible. And, of course, you can use linear filtering aswell.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.