EXA component alpha
Eric Anholt
eta at lclark.edu
Fri Jan 6 17:36:09 PST 2006
On Fri, 2006-01-06 at 23:32 +0100, Thomas Hellström wrote:
> Eric Anholt wrote:
>
> >On Thu, 2006-01-05 at 13:10 +0100, Thomas Hellström wrote:
> >
> >
> >>Hi!
> >>
> >>While working with via composite acceleration I've come across
> >>situations where the src picture is ABGR8888 and the mask is ARGB8888.
> >>
> >>Is the four component mask intended to be used as component alpha or
> >>should the RGB data be ignored and the A channel be used as alpha for
> >>all channels on the source?
> >>
> >>
> >
> >If the component alpha flag on the mask (pMask->componentaAlpha) is set,
> >then you need to do component alpha blending with it. If you could
> >manage to do that with via hardware in one pass, congratulations, you've
> >got features that aren't in radeons, r128, 3dfx, sis, mga, etc.
> >
> Thanks. Hmm, according to the docs it should be OK. The unichrome
> texture engines seem quite flexible when it comes to different
> blending modes, but they are not very fast. Translucent windows are
> just barely enjoyable in 24 bit mode :).
Keep in mind, the texture combining to get the source-color value isn't
the hard part. It's the actual blending using the source-alpha value
that is.
Equations may help, since I've never found a prose description that
really works. Let's use Over, since everyone loves it. The equation
for non-component-alpha Over is:
srcv.A = src.A * mask.A
srcv.R = src.R * mask.A
srcv.G = src.G * mask.A
srcv.B = src.B * mask.A
dst.A = srcv.A + (1 - srcv.A) * dst.A
dst.R = srcv.R + (1 - srcv.A) * dst.R
dst.G = srcv.G + (1 - srcv.A) * dst.G
dst.B = srcv.B + (1 - srcv.A) * dst.B
Expanded, that's:
dst.A = src.A * mask.A + (1 - (src.A * mask.A)) * dst.A
dst.R = src.R * mask.A + (1 - (src.A * mask.A)) * dst.R
dst.G = src.G * mask.A + (1 - (src.A * mask.A)) * dst.G
dst.B = src.B * mask.A + (1 - (src.A * mask.A)) * dst.B
But for component-alpha Over, it's:
srcv.A = src.A * mask.A
srcv.R = src.R * mask.A
srcv.G = src.G * mask.A
srcv.B = src.B * mask.A
srca.A = src.A * mask.A
srca.R = src.A * mask.R
srca.G = src.A * mask.G
srca.B = src.A * mask.B
dst.A = srcv.A + (1 - srca.A) * dst.A
dst.R = srcv.R + (1 - srca.R) * dst.R
dst.G = srcv.G + (1 - srca.G) * dst.G
dst.B = srcv.B + (1 - srca.B) * dst.B
Expanded, that's:
dst.A = src.A * mask.A + (1 - (src.A * mask.A)) * dst.A
dst.R = src.R * mask.A + (1 - (src.A * mask.R)) * dst.R
dst.G = src.G * mask.A + (1 - (src.A * mask.G)) * dst.G
dst.B = src.B * mask.A + (1 - (src.A * mask.B)) * dst.B
Most people approaching component alpha acceleration (including myself,
originally) try to use the texture combiners to just multiply the
components of src per-component with mask, and then use the blenders
with that result just like non-CA. But that results in:
dst.A = src.A * mask.A + (1 - (src.A * mask.A)) * dst.A
dst.R = src.R * mask.R + (1 - (src.A * mask.A)) * dst.R
dst.G = src.G * mask.G + (1 - (src.A * mask.A)) * dst.G
dst.B = src.B * mask.B + (1 - (src.A * mask.A)) * dst.B
I suppose you could try to use blending of (ONE, ONE_MINUS_SRC_COLOR),
but that just gets you:
dst.A = src.A * mask.A + (1 - (src.A * mask.A)) * dst.A
dst.R = src.R * mask.R + (1 - (src.R * mask.R)) * dst.R
dst.G = src.G * mask.G + (1 - (src.G * mask.G)) * dst.G
dst.B = src.B * mask.B + (1 - (src.B * mask.B)) * dst.B
--
Eric Anholt eta at lclark.edu
http://people.freebsd.org/~anholt/ anholt at FreeBSD.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg/attachments/20060106/cd023c74/attachment.pgp>
More information about the xorg
mailing list