Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411558 Posts in 69384 Topics- by 58443 Members - Latest Member: junkmail

May 03, 2024, 11:56:04 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)CreativeRemoving pink backgrounds in GIMP?
Pages: [1]
Print
Author Topic: Removing pink backgrounds in GIMP?  (Read 5435 times)
LemonScented
Level 7
**



View Profile
« on: January 06, 2010, 03:10:53 PM »

Sorry, I didn't know if this was a technical question or an art question, so I've split the difference and put it here...

I'm using some Assemblee assets that came on that standard "remove me pink" coloured background. Since it's within the spirit of the rules, the easiest thing for me to do is to open up the images in GIMP ('s'what I use for art stuff - I've got a version of Photoshop kicking around but it's a bit technical and fiddly for my non-artistic tastes), add an alpha channel, and then use the magic wand to select all of the pink and delete it, then save the texture. But weirdly, when I render the image ingame, some of the pink comes back:



GIMP shows no pink at all, but it's still there in the game. It seems to be a problem with every texture I remove the pink from in this way. Can anyone tell me what I'm doing wrong, and how I can fix it?
Logged

george
Level 7
**



View Profile
« Reply #1 on: January 06, 2010, 04:14:55 PM »

I tried two methods of removing the pink and then rendering as a png (with OpenGL). First:



That was by using Colors -> Color to Alpha and using the selected magic pink color.

Then I tried your method, added alpha channel, then Select -> By Color + ctrl-x.



So, while obviously the two methods have different effects I don't see any trace of the pink like you did, even with an extreme zoom, so I'm puzzled by what you're getting.
Logged
LemonScented
Level 7
**



View Profile
« Reply #2 on: January 06, 2010, 06:25:11 PM »

I tried Colours-> Colour to Alpha, but that makes parts of the actual sprites semi-transparent, which isn't what I want (and is probably why the sprites you tested looked different too).

I've fixed the problem now, although I still don't know exactly where things went wrong... If I move the image in GIMP so that there are no solid pixels on the edges of the texture (or resize the canvas so that there's a pixel border of transparent pixels), it seems to fix it. I can buy the idea that there might be some kind of floating point error to do with UVs and texture wrapping in my engine somewhere (it seems unlikely, but not impossible). But I still don't know where my engine is/was getting the pink colour from when it no longer appeared in the texture. Weird...
Logged

FatHat
Level 1
*



View Profile
« Reply #3 on: January 07, 2010, 05:02:42 PM »

So, here's what I think the problem is: Bilinear filtering. When you delete the pixels in gimp, you're setting them to be transparent -- but they still have their color component. So, you have a bunch of invisible pink pixels.

Bilinear filtering is going to pull in colors from neighboring pixels. And those neighboring pixels are going to be the pink abominations.

Easiest thing to do is probably turn off linear filtering, or smudge the colors outwords from the edges before you delete the pixels (tho I dunno if that's allowed by the competition?
Logged
Lon
Level 4
****



View Profile
« Reply #4 on: January 09, 2010, 05:31:07 PM »

I to did Color->Alpha in GIMP and used the images in my game.  There wasn't any hint of pink around the GFX till I switched to using OpenGL to draw the Graphics.  This is where I ran into the same problem, the pink glow.  I remember reading this thread just a few days ago... hopefully a solution can/has been found.

So, here's what I think the problem is: Bilinear filtering. When you delete the pixels in gimp, you're setting them to be transparent -- but they still have their color component. So, you have a bunch of invisible pink pixels.

Bilinear filtering is going to pull in colors from neighboring pixels. And those neighboring pixels are going to be the pink abominations.

Easiest thing to do is probably turn off linear filtering, or smudge the colors outwords from the edges before you delete the pixels (tho I dunno if that's allowed by the competition?

Ah, thanks FatHat, sounds quite reasonable.  Ill see if I can mess with gimp to remove this color component from alpha, or if I can change some setting with OpenGL to resolve this 'pink glow'.  Ill report back when I find what works.
Logged

“We all sorely complain of the shortness of time, and yet have much more than we know what to do with. Our lives are either spent in doing nothing at all, or in doing nothing to the purpose, or in doing nothing that we ought to do..." -Seneca
LemonScented
Level 7
**



View Profile
« Reply #5 on: January 10, 2010, 07:26:06 AM »

I tried turning off bilinear filtering, but it didn't really improve things. For most of the sprites I had this problem with, I ended up just flood-filling the pink area in another colour (black, or white, depending on the sprite) before deleting it. Seemed to work fine that way.
Logged

Lon
Level 4
****



View Profile
« Reply #6 on: January 11, 2010, 03:36:29 PM »

I tried turning off bilinear filtering, but it didn't really improve things. For most of the sprites I had this problem with, I ended up just flood-filling the pink area in another colour (black, or white, depending on the sprite) before deleting it. Seemed to work fine that way.

I ended up flood filling the nearby pixels with a color similar to that of the border color (usually black) as well.  But what do you do with sprites with sprites without single color borders?  Would black fill (0,0,0 RGB) work fine for non-black-outlined sprites?
Logged

“We all sorely complain of the shortness of time, and yet have much more than we know what to do with. Our lives are either spent in doing nothing at all, or in doing nothing to the purpose, or in doing nothing that we ought to do..." -Seneca
FatHat
Level 1
*



View Profile
« Reply #7 on: January 11, 2010, 05:03:36 PM »

I tried turning off bilinear filtering, but it didn't really improve things. For most of the sprites I had this problem with, I ended up just flood-filling the pink area in another colour (black, or white, depending on the sprite) before deleting it. Seemed to work fine that way.

I ended up flood filling the nearby pixels with a color similar to that of the border color (usually black) as well.  But what do you do with sprites with sprites without single color borders?  Would black fill (0,0,0 RGB) work fine for non-black-outlined sprites?

I think you'd still have the same issues, but it would be much more subtle (harder to notice slight darkness over glaring pink).

Kinda surprised disabling the linear filtering didn't work. Is mip mapping on?
Logged
Petethegoat
Level 1
*


Pete Goodfellow


View Profile WWW
« Reply #8 on: January 12, 2010, 09:41:21 AM »

I'm not sure if this is quite the same as your problem, but you may find this blog post by Wolfire interesting; http://blog.wolfire.com/2009/01/scaling-images-with-alpha/

Hopefully some of that is relevant. Gentleman
Logged
Lon
Level 4
****



View Profile
« Reply #9 on: January 14, 2010, 11:33:10 PM »

I tried turning off bilinear filtering, but it didn't really improve things. For most of the sprites I had this problem with, I ended up just flood-filling the pink area in another colour (black, or white, depending on the sprite) before deleting it. Seemed to work fine that way.

I ended up flood filling the nearby pixels with a color similar to that of the border color (usually black) as well.  But what do you do with sprites with sprites without single color borders?  Would black fill (0,0,0 RGB) work fine for non-black-outlined sprites?

I think you'd still have the same issues, but it would be much more subtle (harder to notice slight darkness over glaring pink).

Kinda surprised disabling the linear filtering didn't work. Is mip mapping on?

What you have said makes total sense.  After a bit of experimentation and web browsing about disabling and changing the settings of blending I found that:
A) As you said FatHat (I believed you, I just couldn't figure out how to disable linear filtering) disabling linear filtering resolves this issue, (see http://gregs-blog.com/2008/01/14/how-to-turn-off-bilinear-filtering-in-opengl/ , also Petethegoats link is relevant)
Code used:
Code:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

B) Alpha Check/test to not blend fully transparent pixels resolves this issue as well if I recall correctly.  Though this may have other undesired effects...
Code:
glEnable (GL_ALPHA_TEST );
gl.glAlphaFunc (GL_EQUAL, 1);

Thanks FatHat!

I was having troubles with the texture borders being visible when rendering with OpenGL (see http://www.opengl.org/resources/code/samples/sig99/advanced99/notes/node64.html I think this is related to my issue), though using the above methods appear to help resolve this issue. Smiley

I also found this link informative: http://www.opengl.org/resources/faq/technical/transparency.htm

How would I go about enabling blending so that it does not spill colors of transparent pixels onto other non-transparent pixels, but still blends non transparent pixels colors with transparent pixels on the same texture?  There are some interesting blending options using OpenGL see (http://www.opengl.org/sdk/docs/man/xhtml/glBlendFunc.xml).

Thanks
Logged

“We all sorely complain of the shortness of time, and yet have much more than we know what to do with. Our lives are either spent in doing nothing at all, or in doing nothing to the purpose, or in doing nothing that we ought to do..." -Seneca
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic