Page 1 of 1
Transparency issues
Posted: Sun Nov 23, 2008 5:28 am
by Lord Tim
Hello, all.
I've been working on my latest game in none other than the wonderous Löve, and I've come across a strange glitch. Some of my sprites have thin magenta borders around them, while other do not. I am using magenta as the transparency color, but the other parts that are magenta are transparent as they should be. I am using
mtPaint to create my images (.png).
Here's an example:
(The guy on the top's x/y/a is connected to a physics object, the bottom is a static sprite, both are drawn from love.graphics.draw(sprite,x,y,a) with the same Image object)
Is this because of the way I'm making the actual image? Or is it a Löve/Lua/OpenGL issue? Any way to fix it?
Re: Transparency issues
Posted: Sun Nov 23, 2008 12:57 pm
by qubodup
Anti-aliasing?
Are the bordered images JPG? (Well, if you say PNG, apparently not)
Please upload a working and a not-working image.
Curiosity: Why do you use a color instead of real transparency?
PS: Perhaps it has to do with 'indexed' status of the images.
PPS: Maybe uploading the code would help too.
Re: Transparency issues
Posted: Sun Nov 23, 2008 3:31 pm
by rude
This is probably due to how PNG handles transparent textures when scaled/rotated/translated. I added a feature a while back (which noone cared about at the time) which took care of this problem. I tested it a while ago, and it seems to be broken in 0.5.0.
Typical.
You can try it if you want, maybe I'm mistaken. Load the image like this:
Code: Select all
image = love.graphics.newImage("fist.png", love.image_optimize)
If you math.floor the x,y-position before drawing the sprite, the problem will go away, though. (Unless you scale/rotate it). Of course, that will also lead to non-smooth movement.
Re: Transparency issues
Posted: Sun Nov 23, 2008 5:28 pm
by Lord Tim
Cool, thanks for that.
I had already tried out the optimize setting before, but yeah, doesn't fix the problem.
Is there a better way to add the transparency to images? I'm a bit new at that, and the index option seemed the easiest.
Re: Transparency issues
Posted: Sun Nov 23, 2008 6:14 pm
by bartbes
Gimp has an option to convert a color to alpha, don't know exactly if it works as you need it to, it is located under color (and is called color to alpha, or something similar).
Re: Transparency issues
Posted: Sun Nov 23, 2008 6:39 pm
by Lord Tim
Would a different image format not have this problem? Like if I used .gif instead?
Re: Transparency issues
Posted: Sun Nov 23, 2008 6:40 pm
by qubodup
bartbes wrote:Gimp has an option to convert a color to alpha, don't know exactly if it works as you need it to, it is located under color (and is called color to alpha, or something similar).
I do it by right-clicking the layer (in the layer dialog) and clicking "add alpha to layer" then, when you erase or delete (DEL) pixels, they are transparent.
Re: Transparency issues
Posted: Sun Nov 23, 2008 7:29 pm
by rude
If you fill the magenta areas with black and use a TGA transparency mask for the transparent areas it will probably solve your problem.
Re: Transparency issues
Posted: Sun Nov 23, 2008 7:45 pm
by Lord Tim
Ah. Thanks. Using .tga fixes this.