Does everyone just alpha blend there sprites now ?

BlitzMax Forums/BlitzMax Beginners Area/Does everyone just alpha blend there sprites now ?

Dax Trajero(Posted 2006) [#1]
Now we have BlitzMax, does everyone use the alpha to overlay there sprites onto a background instead of masking ?

I've just done 32 frames of sprites of which I had to apply a background colour for the mask. Instead, with BlitzMax I can just alpha blend them.


deps(Posted 2006) [#2]
Alpha all the way here. :)


RiK(Posted 2006) [#3]
Alpha FTW... :)


FlameDuck(Posted 2006) [#4]
Yes.


Tom Darby(Posted 2006) [#5]
Alpha, alpha, alpha, alpha, alpha, alpha, alpha, alpha, alpha, alpha, mipmapping, and alpha.


tonyg(Posted 2006) [#6]
Yes


Gabriel(Posted 2006) [#7]
Monorail!

I mean Alpha.


GfK(Posted 2006) [#8]
Masking can be faster than alpha. I only use alpha if I need to - not just for the sake of doing it.


Dax Trajero(Posted 2006) [#9]
GfK, interesting you say that. Would you say that if I told you I only had 10 50x50 sprites on screen @ 800x600 ?


Dax Trajero(Posted 2006) [#10]
thanks all - great comments as ever.


Grey Alien(Posted 2006) [#11]
Yes, all the time so everything looks lush.


ImaginaryHuman(Posted 2006) [#12]
In OpenGL terms at least, here's some things to keep in mind:

Having the ability to draw masked and having the ability to draw with alpha blending consumes the same amount of video ram regardless. A 24-bit RGB image is going to have an 8-bit alpha channel regardless of whether you use it to alphablend or to do masking. The main difference between masking or alpha blending is how the alpha channel data is used. You aren't saving any memory by just using masking, but you are saving some speed...

Doing alpha blending is slower because it has to switch on `blending` in the graphics pipeline, which means reading the content of the destination pixels and combining them with the incoming value for the new pixels using the source image, the ratio of which is determined by the alpha channel value. When you just do masking, blending is not required, and instead the `alpha test` is used to just look at the incoming alpha channel value and see if it meets a given threshold (ie 0.5 (127)). It doesn't require reading the backbuffer or doing a crossfade with blending. So masking is usually faster than alphablending but then you only get `either on or off` behavior rather than multiple levels of transparency (as in antialiasing). But alphablending is generally nicer and more flexible. You technically can actually do both masking and alphablending at the same time - you could accept only pixels with alpha values >0.5 (half intensity) and then alpha-blend those pixels with the destination. But that's not part of the standard Max commands.