[Public WebGL] Compositing with HTML
Fri Jan 8 15:26:05 PST 2010
On Fri, Jan 8, 2010 at 10:38 AM, Chris Marrin <[email protected]> wrote:
> On Jan 8, 2010, at 10:24 AM, Kenneth Waters wrote:
> >> If you do this test in WebKit it seems to do the right thing. Over white
> the clear color looks the same because of clamping, but over other colors
> the red is too bright. But if you do this in Firefox, it looks wrong. Over
> white, you get gray! In fact, any red component over 0.5 gives you the same
> result. So it looks like when Firefox gets a color component over 1.0, it
> replaces the entire color with black or something. Is this a bug in Firefox?
> > I think this is undefined behavior. My personal preference is that
> > the color channels are clammed to alpha, unless its specified
> > differently elsewhere. Seems like this should go into section 5.1.1
> > of the spec.
> I believe this behavior is specified in the HTML spec, so I don't think we
> need to make any additional definitions here.
> >> Maybe there's nothing we need to do here.
> > OpenGL doesn't have a concept of premultiplied or unpremultiplied
> > alpha. You can use OpenGL to blend in either space. I don't think we
> > need to do anything about it here, beyond what we've already said in
> > the WebGLContextAttributes, and to define what happens for out of
> > range values.
> >> But we at least need to make a notation that clearColor does not obey
> the blendFunc and the values you specify go into the color buffer directly,
> so you need to take this into account if your color buffer is premultiplied.
> > I think this is spelled out quite well in the GL-ES 2.0 spec, "The GL
> > provides a means for setting portions of every pixel in a particular
> > buffer to the same value." "When Clear is called, the only
> > per-fragment operations that are applied (if enabled) are the pixel
> > ownership test, the scissor test, and dithering" (section 4.2.3).
> OpenGL is different from other API's in this class in that it doesn't try
> to help the author much with the premultiplied vs un-premultiplied issue.
> It's a real issue, and it came up because one of my co-workers, who is very
> familiar with HTML rendering, got really confused by the fact that you have
> to worry about premultiplication in the clearColor. Since we will have a
> large audience of developers familiar with other web tech, we owe it to them
> to point out this issue.
I agree that this is confusing and worth at least a couple of sentences in
the spec with details on what needs to be done to produce correct
pre-multiplied colors as expected by the WebGL canvas. It's a matter of:
1. Clearing with correct pre-multiplied colors.
2. Outputing pre-multiplied colors from pixel shaders.
3. Setting the blend modes such that they blending is correct assuming
pre-multiplied colors for both source and target
> [email protected]
> You are currently subscribe to [email protected]
> To unsubscribe, send an email to [email protected] with
> the following command in the body of your email:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the public_webgl