GLBasic forum

Main forum => Bug Reports => Topic started by: spicypixel on 2012-Apr-26

Title: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: spicypixel on 2012-Apr-26
Overlay this smooth transparent alpha gradient over a full screen image and you will see the alpha is not smooth but has a banded edge. Try using a light coloured image to overlay on top of as it will depict the problem far better.

This needs fixing as true alpha is not being represented properly :-(

[attachment deleted by admin]
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: MrTAToad on 2012-Apr-26
Are you using SMOOTHSHADING ?
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: spicypixel on 2012-Apr-26
Yep set to TRUE, although changing it to FALSE or completely commenting it out makes no difference :-(
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: spicypixel on 2012-Apr-26
This is what I get with GLB compared to Photoshop.

[attachment deleted by admin]
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: monono on 2012-Apr-26
Did you try using -0.9999 instead of -1?
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: Slydog on 2012-Apr-26
I noticed this same problem when adding my fake blob shadows.
They would band at the edges, no matter what alpha values I chose.

I did an experiment and found that the cut-off for the alpha was around 15 (out of 255).
Any alpha below this wouldn't render, and the first value above would show not very transparent.

I used the command 'ALPHATESTING 0' and the problem went away.
Not sure if this is set once, or per frame.

Hope this helps you in your situation.
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: fuzzy70 on 2012-Apr-26
I just tested with 'ALPHATESTING 0' & it did cure the problem.

Lee
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: Slydog on 2012-Apr-26
Here are my before and after shots of my shadow:


[attachment deleted by admin]
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: Sixth Sense on 2012-Apr-26

QuoteI did an experiment and found that the cut-off for the alpha was around 15 (out of 255).

Slydog, If you have the time could you expand a little on what you meant by the above please.
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: Slydog on 2012-Apr-26
In my 'before' screenshot above, notice how the shadow suddenly turns to fully transparent, creating a visible line cutoff around the shadow, as opposed to a gradual fading out of the alpha as seen in the 'after' shot.

What I did to find this '15' value was in Paint.NET I created various rectangles over top of my shadow sprite.
Each rectangle had an different alpha value, gradually increasing.
You can set/view the alpha in the 'Colors' dialog.
Whenever I used a rectangle with an alpha below 15, it would not render in GLBasic.
Any alpha above this cutoff would show a transparent rectangle with a distinct edge.

Again, the '15' value is from memory, could be a little higher / lower.
I was just trying to figure out whether I was using the blurring tools properly. 
I guess I was and GLBasic was to blame! :D
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: Moru on 2012-Apr-26
Yes, I had similar problems but this was in version 8 or so. Haven't done much with alpha since then. Alpha only changed every 8 or 16 steps, can't remember more exactly but it felt like there was a bit missing somewhere.
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: Slydog on 2012-Apr-26
Ha, ya I guess with that number 15/16 it appears to be only 4 bits, funny how I didn't notice this!
But is it only 4 bits, or does it just cut-off/ignore the lowest 15 alpha values?
The remaining gradient appears to be smooth.  (or does it?!)

But then the question is: why does 'ALPHATESTING 0' fix the problem?
Or at least APPEAR to fix the problem?
What does this command do behind the scenes?
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: erico on 2012-Apr-26
After you find the color space it is using, you can dither to achieve similar results maybe O_O
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: kaotiklabs on 2012-Apr-26
Using ALPHATESTING 0 has also fixed some problems with alpha not been applied with alphamode -1 .
So I dont know whats happening but it works!
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: Kitty Hello on 2012-Apr-26
alphatesting will test and make all pixels of alpha < 0.05 be totally transparent. (no blending)
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: spacefractal on 2012-Apr-27
I have been confuction about this issue as well (so called multiply issues). Here I fixed it by using ALPHATESTING 1.

Those kind of issues should have been documents in the help file, since its can been very confuction about it.
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: spicypixel on 2012-Apr-27
Regardless of ALPHATESTING value fixing it. ALPHAMODE -1 should just work shouldn't it? I'm looking at the ALPHATESTING in the help file and at first glance can't make head nor tail of it :)
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: spicypixel on 2012-May-07
ALPHATESTING 0 each frame works perfectly.
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: Wampus on 2012-May-10
One oddity I found is that alpha blending seems to work fine for my images if ALPHATESTING 0 or ALPHATESTING 1.0 is used each loop but not if ALPHATESTING is not called at all. In the help file it states that ALPHATESTING 1.0 totally disables alpha tests.

So...I guess I'll be using ALPHATESTING 1.0 and also having correct alpha blending then.  O_O
Title: Re: Alpha Transparency is wrong in GLB using Alphamode -1
Post by: Kitty Hello on 2012-May-10
alphatesting only decides what source alpha will be considered as a hole in your sprite. No pixel will be drawn, no z-buffer will be touched if alphatesting skips.