From: William B. <wb...@ho...> - 2001-03-02 17:07:17
|
On Fri, 2 Mar 2001, Keith Packard wrote: > Yes, but it commutes into the OP dest part as well; you must carry four > alpha values along with four pixel values. Here's an example (all four > components are exactly the same (even alpha (the joys of premultiplied > pixels))): > > dst = (src IN msk) OVER dst > > Normal compositing: > > dst_r = src_r * msk_a + dst_r * (1 - src_a * msk_a) > dst_g = src_g * msk_a + dst_g * (1 - src_a * msk_a) > dst_b = src_b * msk_a + dst_b * (1 - src_a * msk_a) > dst_a = src_a * msk_a + dst_a * (1 - src_a * msk_a) Well, the mach64 will do this one (with only 4 bits of significance). > Per component compositing: > > dst_r = src_r * msk_r + dst_r * (1 - src_a * msk_r); > dst_g = src_g * msk_g + dst_g * (1 - src_a * msk_g); > dst_b = src_b * msk_b + dst_b * (1 - src_a * msk_b); > dst_a = src_a * msk_a + dst_a * (1 - src_a * msk_a); > > The key distinction is that the mask alpha value used in both parts of the > sum is per-component. The sympatic Plan9 function extends to this case > without even blinking, but I don't think hardware can do this. This one will require more thought... One question; what is the difference between a (Rs,Gs,Bs,As) DEST blend function and a (As,As,As,As) DEST blend function when we are talking about per-primary alpha compositing? (in the uniform case the answer's seems obvious), Perhaps some degree of function substitution is possible... > > Only one problem: I am not certain what happens to the destination's alpha > > channel (RGBA8888 or RGBA5551). The SRC and DEST blending functions don't > > document how the alpha channel is handled [except for Saturate where the > > SRC blend factor is (f,f,f,1) where f = min(As,(1-Ad)]. > > OpenGL says that the dest alpha value gets the computed alpha; certainly > this is true for Saturate (otherwise it wouldn't work). Of course, at > 1555, there's not much space for the dest alpha, but in that case, Render > allows a separate alpha channel to hold the result (not that I've coded > the separate alpha channel, but the protocol allows it). Separate alpha channel? Ouch, the mind boggles at doing that trick in hardware... > Because Saturate must store the correct value, and because OpenGL spec > says the alpha value out of the composite operator is computed and saved, > I believe the hardware will be forced to do the right thing. Suitable > experiements could quickly determine this. Cool. I think its time to write a little experimental code... for the uniform case at least *grin*. PS: I hope you have a nicer weekend! Here in Vancouver BC its raining... -- William Blew, wb...@ho... Gamer by Choice, Geek by Birth |