BASIC

Author Topic: Alpha Transparency is wrong in GLB using Alphamode -1  (Read 5862 times)

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
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]
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

MrTAToad

  • Guest
Are you using SMOOTHSHADING ?

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
Yep set to TRUE, although changing it to FALSE or completely commenting it out makes no difference :-(
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
This is what I get with GLB compared to Photoshop.

[attachment deleted by admin]
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Offline monono

  • Mr. Polyvector
  • ***
  • Posts: 213
    • View Profile
    • Sockel Lernmedien
Did you try using -0.9999 instead of -1?

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
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.
« Last Edit: 2012-Apr-26 by Slydog »
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
I just tested with 'ALPHATESTING 0' & it did cure the problem.

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
Here are my before and after shots of my shadow:


[attachment deleted by admin]
« Last Edit: 2012-Apr-26 by Slydog »
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline Sixth Sense

  • Mc. Print
  • *
  • Posts: 47
    • View Profile
    • Sixth Sense

Quote
I 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.
Okay, It’s been more than ten years now so I confess............I let the dogs out!

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
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
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1774
    • View Profile
    • Homepage
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.

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
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?
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4212
    • View Profile
    • Portfolio
After you find the color space it is using, you can dither to achieve similar results maybe O_O

Offline kaotiklabs

  • Dr. Type
  • ****
  • Posts: 313
  • Spain is diferent
    • View Profile
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!
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10709
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
alphatesting will test and make all pixels of alpha < 0.05 be totally transparent. (no blending)