[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Compositing with HTML





On Fri, Jan 8, 2010 at 10:38 AM, Chris Marrin <cmarrin@apple.com> 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.

Just for my own personal clarification. Clamping to alpha is not what the current implemenations do (maybe firefox does this?)
The comment above seems to be suggesting that all implementations clamp to alpha.

 

>
>> 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.

-----
~Chris
cmarrin@apple.com




-----------------------------------------------------------
You are currently subscribe to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: