Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Calin Leafshade on Fri 15/01/2010 16:56:08

Title: A strange problem relating to Alpha channels.
Post by: Calin Leafshade on Fri 15/01/2010 16:56:08
ok kids.. this is a weird one.

Using 3.1.2:

For some reason alpha chanels will not work with any raw draw function. I know the drawing surface doesnt support alphas but this is on the background.. and its still not working.

Also the rain plugin just sends down white blocks and isnt using the alpha channel but alpha channels work just fine in objects.

Any ideas? Im thinking my project file might be corrupt.. anywhere particular i should look?

??? ??? ???
Title: Re: A strange problem relating to Alpha channels.
Post by: GarageGothic on Fri 15/01/2010 17:01:42
What's the color depth of the background?
Title: Re: A strange problem relating to Alpha channels.
Post by: Calin Leafshade on Fri 15/01/2010 17:07:53
32-bit, and its a 32-bit game.
Title: Re: A strange problem relating to Alpha channels.
Post by: Ryan Timothy B on Fri 15/01/2010 17:14:34
Have you checked if the sprites with alpha channel work properly on a character/object?
edit: Sorry, I must be blind.  My guess was that those rain droplets were imported or saved incorrectly.
Title: Re: A strange problem relating to Alpha channels.
Post by: Calin Leafshade on Fri 15/01/2010 17:16:54
Quote from: Calin Leafshade on Fri 15/01/2010 16:56:08
but alpha channels work just fine in objects.

alpha channels behave as normal in objects and animations.. just not in drawimage or in the rain plugin.

What annoys me most is that ive only just noticed the problem.. i dont feel like importing more than 500 sprites again..
Title: Re: A strange problem relating to Alpha channels.
Post by: Ryan Timothy B on Fri 15/01/2010 17:40:14
Actually something like this has happened to me a few months ago.  Did you start out the game with 16bit color, then after importing the sprites you changed it to 32bit?

I did that once, but it was a fresh game and I had only imported a few sprites in the sprite manager.  The  DrawingSurface.DrawImage  would paste the sprite onto the background in a complete weird whiteish color, and those sprites didn't even have alpha.  Even after reimporting the sprites into the sprite manager and background, it still didn't fix the problem so I made a new game.
Title: Re: A strange problem relating to Alpha channels.
Post by: Calin Leafshade on Fri 15/01/2010 17:48:40
Yes that sounds exactly like my problem. Does anyone know of a way to fix this WITHOUT nuking my game?

Dear God(CJ), is there anyway of fixing this?
Title: Re: A strange problem relating to Alpha channels.
Post by: Ryan Timothy B on Fri 15/01/2010 17:51:36
Try drawimage with a sprite that doesn't have an alpha on the background, if you haven't.  Then we'll see if it's the same unknown weirdness I had experienced.
Title: Re: A strange problem relating to Alpha channels.
Post by: Calin Leafshade on Fri 15/01/2010 18:01:18
hmm ok.

It will draw sprites without an alpha channel at any transparancy and it will draw sprites will alpha channels at 0 transparency.. but it wont draw alpha channeled sprites at anything other than 0 transparency.
Title: Re: A strange problem relating to Alpha channels.
Post by: GarageGothic on Fri 15/01/2010 18:13:54
This is strange. It would be expected behavior for any AGS version before  3.1.2, but this quote from the 3.1.2 changelist seems to say it should work now:

QuoteAdded support for using Transparency properties with alpha-channel sprites

Not sure if it's also implemented for DrawingSurface or just characters/objects though.
Title: Re: A strange problem relating to Alpha channels.
Post by: Calin Leafshade on Fri 15/01/2010 18:17:03
Well, i've done this before and the particle system manager module uses it extensively.

It certainly supported.
Title: Re: A strange problem relating to Alpha channels.
Post by: monkey0506 on Fri 15/01/2010 19:10:48
I'm actually quite certain that the DrawingSurface.DrawImage function has never supported drawing alpha channeled sprites at partial transparency. The "Transparency properties" you are referring to there GG is talking about Character.Transparency, Object.Transparency, and GUI.Transparency.
Title: Re: A strange problem relating to Alpha channels.
Post by: Calin Leafshade on Fri 15/01/2010 19:21:33
Well then how come the snowrain plugin has exactly the same problem?
Title: Re: A strange problem relating to Alpha channels.
Post by: monkey0506 on Fri 15/01/2010 19:38:22
Actually I just tested it and what I'm getting is that the sprite is simply being flattened before (the transparency is applied and) it's drawn to the background. This is happening regardless of whether using a direct sprite slot or using a DynamicSprite created from the slot and preserving the alpha channel. I'm using the latest 3.2 RC though nothing on the changelog seems relevant to this issue.

Guess I was just talking bullocks. := (Though seeing as the alpha channel is being destroyed by calling DrawImage it's not strictly working as one might be expecting anyway)
Title: Re: A strange problem relating to Alpha channels.
Post by: TheMagician on Wed 17/02/2010 23:21:58
Quoteseeing as the alpha channel is being destroyed by calling DrawImage it's not strictly working as one might be expecting anyway

I just found that out myself ... too bad - didn't this work a few versions ago? I mean, is there any workaround? I really need to draw an alpha-transparent sprite onto a DrawingSurface...
Title: Re: A strange problem relating to Alpha channels.
Post by: monkey0506 on Thu 18/02/2010 05:20:08
You can draw images with an alpha channel onto a DrawingSurface. This will work fine and without problem (the stipulation below being considered "by-design" for now).

You cannot copy or merge alpha channels by using DrawingSurface.DrawImage. Whenever you use DrawImage the transparency is applied to the pixels as they are drawn, but the resulting image (in the DrawingSurface) has no alpha channel.

If you draw an alpha channeled image onto a transparent area of a DrawingSurface this means your sprite will be tinted pink.

However, so long as the area behind the sprite is totally opaque then you can get the same visual effect the alpha channel provides whilst using the DrawImage function.
Title: Re: A strange problem relating to Alpha channels.
Post by: subspark on Thu 25/02/2010 02:45:38
Yeah alpha channels are really buggy in AGS right now. I beleive I sent CJ on a quest to fix them two weeks ago in regards to inventory items and quite possibly everything else in effect.

I hope they all get solved in one big hit.  :D

Cheers,
Sparky.