PNG alpha channel problems

Started by Akril15, Tue 19/02/2013 03:39:43

Previous topic - Next topic

Crimson Wizard

Quote from: Knox on Wed 02/10/2013 17:11:10
Yep, that's what I meant. I have semi-transparent shadows under the text window (so the corners and sides have semi-transparent shadows, the center is opaque).

Did that; and also added "HasAlphaChannel" property to DialogOptionsRenderingInfo class, so that custom options rendering could have alpha sprites:

Spoiler


[close]
Spoiler


[close]

monkey0506

I can't wait for the release of that game CW! 8-) Actually, that's pretty cool! It looks like this allows drawing semi-transparent sprites against a transparent background? Would it be possible to also draw an anti-aliased TTF font against a completely transparent background? That was one feature that I would like...working around it is terrible.

Crimson Wizard

#62
Quote from: monkey_05_06 on Sun 06/10/2013 20:58:40Would it be possible to also draw an anti-aliased TTF font against a completely transparent background? That was one feature that I would like...working around it is terrible.
Hmm, you can already do that in AGS: http://www.adventuregamestudio.co.uk/forums/index.php?topic=47966.msg636469376#msg636469376
The problem arises when you draw AA TTF fonts over translucent surface.


Quote from: monkey_05_06 on Sun 06/10/2013 20:58:40
I can't wait for the release of that game CW! 8-)
lol, game?
Hmm... (roll) hmmmmmm.........

monkey0506

Quote from: Crimson Wizard on Sun 06/10/2013 21:08:58
Quote from: monkey_05_06 on Sun 06/10/2013 20:58:40Would it be possible to also draw an anti-aliased TTF font against a completely transparent background? That was one feature that I would like...working around it is terrible.

Hmm, you can already do that in AGS: http://www.adventuregamestudio.co.uk/forums/index.php?topic=47966.msg636469376#msg636469376
The problem arises when you draw AA TTF fonts over translucent surface.

Umm... no. Because then the text gets a pink outline. When drawing it on a DrawingSurface (NOT A GUI). Unless you expressly fixed that.

Crimson Wizard

#64
Quote from: monkey_05_06 on Sun 06/10/2013 21:27:11
Umm... no. Because then the text gets a pink outline. When drawing it on a DrawingSurface (NOT A GUI). Unless you expressly fixed that.

Just tested this in AGS 3.2.1,"Anti-alias TTF fonts" = True, font is Arial.
Code: ags

// room script file
Overlay *o;
DynamicSprite *s;
function room_AfterFadeIn()
{
  s = DynamicSprite.Create(300, 50, true); // <-- if this is 'false' there's no AA (all text pixels are opaque)
  DrawingSurface *ds = s.GetDrawingSurface();
  ds.Clear(COLOR_TRANSPARENT);
  ds.DrawingColor = Game.GetColorFromRGB(128, 128, 0);
  ds.DrawString(2, 2, eFontFont3, "This line is drawn with TTF");
  ds.Release();
  o = Overlay.CreateGraphical(100, 100, s.Graphic, false); // <-- this can be 'true', result is the same
}


Result:


Do I miss anything?


Things went bad when I added outline though, automatic outline made some letters transparent where they should not be... or maybe it overlapped with wrong offset, hard to say for sure. But still I do not see any pink pixels. :-\

Knox

Quote from: Crimson Wizard on Sun 06/10/2013 18:59:39
Did that; and also added "HasAlphaChannel" property to DialogOptionsRenderingInfo class, so that custom options rendering could have alpha sprites:

Oh yah!!  :grin:
--All that is necessary for evil to triumph is for good men to do nothing.

monkey0506

@CW: Sorry, I remembered wrong about the pink outline. The problem is that the image used for DialogOptionsRenderingInfo is created with no alpha channel so if the background is completely transparent then there is no anti-aliasing. If I clear the surface to non-transparent or draw an image first then anti-aliasing works. Against a transparent background the text is aliased.

Vaunted

#67
Thanks for all the work on this. It's something I was struggling with in older builds, specifically with GUI buttons, and 3.3.0 has fixed a LOT of my problems. I'm still getting some weird issues with alpha blending, however. Specifically, if I use png buttons with alpha transparency in a GUI with a transparent background (bg image and color both 0) using the Multiplied Translucence setting, it leaves a 1-pixel wide faint pink border around each sprite.

(Those left and right arrows are their own images, however, and I notice that THEY don't have a weird border where they blend onto the image behind them.)



I've tried setting the background image to a fully transparent image rather than leaving it as 0, but it just makes the phantom border a deeper shade of pink.

I've also tried using additive opacity instead, and actually does seem to solve the pink border issue! However, it seems to break in the opposite direction, drawing properly onto GUIs with transparent bgs but turning things with an alpha channel drawn onto another image (but only within the same GUI?) into a hideous blob.


Sorry if this is a known issue in the beta, I couldn't find this precise issue being discussed (although it's possible I did and I just didn't understand).

edit: Fixed some erroneous information, forgot how I had the images in the GUI set up. Sorry.

Crimson Wizard

#68
Quote from: Vaunted on Thu 10/10/2013 04:32:53
Thanks for all the work on this. It's something I was struggling with in older builds, specifically with GUI buttons, and 3.3.0 has fixed a LOT of my problems. I'm still getting some weird issues with alpha blending, however. Specifically, if I use png buttons with alpha transparency in a GUI with a transparent background (bg image and color both 0) using the Multiplied Translucence setting, it leaves a 1-pixel wide faint pink border around each sprite.

This is something unexpected. Do you use the latest beta version (#8)?

Quote from: Vaunted on Thu 10/10/2013 04:32:53
I've tried setting the background image to a fully transparent image rather than leaving it as 0, but it just makes the phantom border a deeper shade of pink.
If the background was made of "magic pink" color, then this one is correct behavior, because when translucent image blends over the surface, it uses exactly the background color and does not consider pink as a "magic transparent" color. Instead you could try to create a 32-bit background image where every pixel is RGBA = (0,0,0,0) (shown as "checkered" color in many graphic editors).
If the background was precisely transparent (0,0,0,0), then this might be an error...

Vaunted

Quote from: Crimson Wizard on Thu 10/10/2013 10:56:47
This is something unexpected. Do you use the latest beta version (#8)?
Ack! I checked this before I posted, but I somehow goofed anyway. You're right, I was a couple betas behind. Running it with Multiplied Translucense in beta8 works properly. Thanks, and sorry to have made such a silly mistake.

monkey0506

Is it safe to assume that this:

Quote from: Crimson Wizard on Sun 06/10/2013 18:59:39Did that; and also added "HasAlphaChannel" property to DialogOptionsRenderingInfo class, so that custom options rendering could have alpha sprites...

Is the resolution to this:

Quote from: monkey_05_06 on Sun 06/10/2013 23:15:14@CW: Sorry, I remembered wrong about the pink outline. The problem is that the image used for DialogOptionsRenderingInfo is created with no alpha channel so if the background is completely transparent then there is no anti-aliasing. If I clear the surface to non-transparent or draw an image first then anti-aliasing works. Against a transparent background the text is aliased.

Knox

Hi Crimson,

Everything works ok with alpha on the text windows, however I'm using the SSH's GuiPortrait v1.00 to display speech and it doesn't seem to work with that module (GSay function)http://www.adventuregamestudio.co.uk/forums/index.php?topic=34996.0.

Gsay with GuiPortrait module:


Normal text display works perfectly fine though:


**EDIT: Ok Im not sure if its only me but the normal .Say command doesn't seem to display alpha either?

--All that is necessary for evil to triumph is for good men to do nothing.

SMF spam blocked by CleanTalk