GLBasic forum

Main forum => GLBasic - en => Topic started by: ampos on 2010-Sep-12

Title: gradual alpha gradient
Post by: ampos on 2010-Sep-12
Is there a way to use gradual alpha channel?

Currently, as far as I see, alpha channel is just YES or NO (255,0). Can a gradual alpha channel be used?

I want to cast a gradient shadow.
Title: Re: gradual alpha gradient
Post by: Moru on 2010-Sep-12
It's stated here and there in the manual and tutorials that pink is transparent. If you use PNG images you can use 255 shades of alphachannel in your graphics but you need to set the alphablend in GLBasic to something else than 0. ALPHAMODE -0.1 is fine.
Title: Re: gradual alpha gradient
Post by: Scott_AW on 2010-Sep-12
@Moru - So that's how you get them to work, I didn't know that, thanks!

Alphamode can be set between -1 to 1, with 0 being normal.  And it allows for intervals between.  So -.5 or .5 would be half-transparent.

I believe you can use alphamode in polyvectors...so to create a gradual alpha gradient I think you can do something like this.
Code (glbasic) Select

startpoly 1,0
  alphamode 0 //solid
  // Top of image
  polyvector 0,0,0,0,rgb(255,255,255)
  polyvector 320,0,320,0,rgb(255,255,255)
 
  alphamode 0.5 //half transparent
  // Bottom of image
  polyvector 320,240,320,240,rgb(255,255,255)
  polyvector 0,240,0,240,rgb(255,255,255)

endpoly
Title: Re: gradual alpha gradient
Post by: monono on 2010-Sep-12
Indeed, you can use it in the polyvector block. If you go the alpha png way, you get th finest result with an alpha of -0.9999 in my opinion.
Cheers
Title: Re: gradual alpha gradient
Post by: ampos on 2010-Sep-12
Quote from: Ocean on 2010-Sep-12
Quote from: ampos on 2010-Sep-12
Currently, as far as I see, alpha channel is just YES or NO (255,0)....

I'm eager to learn where you looked or what did read to arrive at this assertion... Can you please give references?

cheers
Ocean

Because I did a PNG with alpha channel and GLB ignored it.

And if you want to GLB not ignoring it, you have to set alphamode -.x, as monono and moru indicated, and GLB does not say.
Title: Re: gradual alpha gradient
Post by: ketil on 2010-Sep-13
Same happened with me when i first tried it, but it was due to an error in my GFX application.
The PNG's was not correct.
Maybe your PNG file is not valid.
Title: Re: gradual alpha gradient
Post by: ampos on 2010-Sep-13
No, it was fine, but if alphamode is not set, they do not work.

You can see a screenshoot of my current work.

http://www.glbasic.com/forum/index.php?topic=5031.0

The shadow of the ball is alphamode -.5

Inner shadows are created using a 32x32 pixels sprite, png, full black with alpha gradient. Then set using polyvector and alphamode -1