EXA component alpha

Thomas Hellström unichrome at shipmail.org
Sat Jan 7 02:31:52 PST 2006


Eric Anholt wrote:


>>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
>>
>>    
>>
Ah. Thanks for the clarification (it must have taken quite some time to 
write down). I must admit I as well had simplified the problem to the 
first set of equations, and the unichromes are not capable of doing the 
correct operation in one pass.
It is easy to be mislead reading the operation definition in 
xc/doc/specs/Render/protocol:

dest = (source IN mask) OP dest

which sort of hints towards that the (source IN mask) operation should 
produce a single RGBA result, which can be composited on the dest.

Anyway the important thing is that a potential user of this operation is 
understanding what the operation really does. Probably needs to go into 
the docs somewhere.

Regards,
Thomas






>------------------------------------------------------------------------
>
>_______________________________________________
>xorg mailing list
>xorg at lists.freedesktop.org
>http://lists.freedesktop.org/mailman/listinfo/xorg
>





More information about the xorg mailing list