Advertisement

alpha blending?

Started by March 22, 2000 11:34 PM
6 comments, last by Aztec 24 years, 9 months ago
does anyone know of any good online tutorials on the topic? are there any good books available? thanks
I''m pretty sure there was an article on GameDev a few weeks ago on it...
Advertisement
I might be completley wrong, but isnt alpha blending the average of overlapping pixels?

red_out=red1+red2/2
green_out=green1+green2/2
blue_out=blue1+blue2/2
=======================Game project(s):www.fiend.cjb.net
I implement my alpha blending via D3D. I think that''s faster than doing it by software...... but you''d had to use a square sprite image.

-------------------------
-Now Working on Pokemon like Engine!
-------------------------
-Now Working on Pokemon like Engine!
quote: Original post by Aztec

does anyone know of any good online tutorials on the topic?
are there any good books available?

thanks


Alpha blending is quite simple really. Given two pixels A and B, the alpha blended result C is given by

C = alpha*A + (1-alpha)*B

where alpha is a transparency value in the range 0 to 1. A faster way to implement this operation is

C = A + alpha*(B - A)

You treat each component (Red, Green and Blue) of A and B seperately. So to actually do implement alpha blending you would do this

Cr = Ar + alpha*(Br - Ar)
Cg = Ag + alpha*(Bg - Ag)
Cb = Ab + alpha*(Bb - Ab)

where the lower-case subscript indicates the equivalent component (r = Red, g = Green, b = Blue).

HTH

Chris

Chris Killpack : ckillpack@ea.com
Technology Group : Bullfrog Productions Ltd
Chris Killpack : ckillpack@eaeurope.comTechnology Group : Bullfrog Productions Ltd
Actually, alpha blending is a bit more complicated than the aove posts imply. Typically, alpha blending is accomplished by setting the inputs of an alpha combine equation. For example, on the PSX2 you have

O = (A - B)*C + D

(other API's have different blending functions)

Where :

O : resulting output color
A : selectable input color (frame buffer, incoming pixel, or 0)
B : selectable input colot (frame buffer, incoming pixel, 0)
C : selectable alpha blending value (frame buffer, input pixel, constant specifiable value)
D : selectable input color

By telling the hardware (or software) what you want for each of the parts of the equation you can get different kinds of blends. Additive ("glows"), filtering (what most people consider "regular" alpha blending), subtractive (subtract a white shadow from a colored polygon and you get a darkened shadow), or any number of others. Glide has an even more sophisticated alpha equation.

Alpha blending can get quite complicated when dealing with multipass issues, antialiasing, polygon sorting, etc. Its one of the more "interesting" areas of modern 3d game development.

Edited by - daveb on 3/23/00 9:21:47 AM
Volition, Inc.
Advertisement
Thanks for the help folks
This Article helped me very much

This topic is closed to new replies.

Advertisement