[Public WebGL] Compositing with HTML
Fri Jan 8 18:26:17 PST 2010
On Jan 8, 2010, at 5:49 PM, Vangelis Kokkevis wrote:
> On Fri, Jan 8, 2010 at 5:36 PM, Chris Marrin <[email protected]> wrote:
> On Jan 8, 2010, at 5:20 PM, Kenneth Waters wrote:
> >> What I mean by that is that color always clamps to 1.0, so if you give oversaturated colors (1.0 when alpha is 0.5, for instance), and blending results in a color greater than 1.0, the result is clamped to 1.0. I believe that is what the HTML compositor specifies and that's what WebKit does when compositing. I think Firefox is doing something different. But I'll wait for Vlad to chime in...
> > Just for clarification how can you get out of range pre-multiplied
> > values into HTML without WebGL?
> That's a good question. The 2D Canvas API can do it using the compositing operators. There they talk about clamping to 1. SVG has similar capabilities. CSS Colors are given in non-premultiplied form and are clamped to 0-1 (or 0-255 if given in that form). So you could say that all the source elements are constrained to have legal premultiplied colors.
> I'm confused. Clamping to 1 doesn't guarantee that it's a legal premultiplied color, does it? Or are you saying that the 2d canvas, svg and css take non-premultiplied colors as input, clamp all the channels to 1 and convert them to pre-mulitplied behind the scenes?
I'm not sure what they actually do, but I know that the spec says 3 useful things:
1) The the fill, stroke and other colors are non-premultiplied
2) Colors in the buffer (when read back) are premultiplied
3) When applying the Porter-Duff compositing operators, the result is clamped to 1
That tells me that if, for instance, you fill a shape, the implementation first premultiplies the fill color (because Porter-Duff operators assume premultiplied alpha), then blend to the color buffer using the equivalent of (ONE, ONE_MINUS_ALPHA) and then clamp the result to 1. Hmm, so I suppose that could result in an oversaturated color (a color component whose value is larger than the alpha value). So maybe the HTML compositor DOES have to deal with this issue.
The problem here is that I can find nowhere in the HTML 5 spec where it talks about the rules of compositing. If someone else can find it that could help the conversation.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the public_webgl