Qbasicnews.com

Full Version: Alpha blending
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I think I have asked this question before. But does anyone have a really fast Alpha Blending routine which I can use with FL? FL's AB routine is quite slow Sad
what does alpha blending mean.
I think it has to do with transparency in sprites,
alpha channel=trans´parency channel
Hmm...If you use WinXP then if you notice that when you select multiple files in Win Explorer by dragging a rectangular square then you will see translucent background with icons. This is an example of alpha blending.

[Image: w2.gif]
When you want to merge two functions, and you want the result to be in the same range as these two functions, you will say:

Result = Alpha * F1 + (1-Alpha)*F2, with 0<=Alpha <=1

If Alpha = 0 then Result = F2, If Alpha = 1 then Result = F1. If Alpha is in-between, you get something in between...

You can apply that to RGB colours:

R = Alpha * R1 + (1-Alpha)*R2
G = Alpha * G1 + (1-Alpha)*G2
B = Alpha * B1 + (1-Alpha)*B2

And you are sure that R, G and B will always remain in the 0-255 range, while the blend is controled by the value of Alpha.

That's the technique used for transparencies, but also reflections (I used something of that kind in TC-Ray).
But you havent answered my underlying question. Is there any prog/add on which will allow me to get faster alpha blending and that can be used with FL?
8 bit, or true/high color?
Specifically for High Color(16bit)
I have downloaded FL a while ago, but I never took time to study it (my own TC-Lib being more adapted to what I do). The reason why I never got into it is that I have never seen the source code: there are only .OBJ files in the zip I have.

Anyway, tweaking the formulas for a fast bit-based routine, compliant with the above-mentioned formulas, must not be very difficult: R, G & B are "single-byte integers", Alpha can also be considered as an single-byte integer (Alpha*255 has a 0-255 range).

Sorry I cannot help more... Maybe you could give the input/output of what you wanna do, and someone could think about an ASM routine that would match the spec...
UGL has one but it's undocumented and therefore I think unfinished... it didn't work extremely well in mode 13h, but I haven't tested the rest =P
Pages: 1 2