Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpha coverage is underspecified #1457

Closed
romainguy opened this issue Sep 27, 2018 · 8 comments
Closed

Alpha coverage is underspecified #1457

romainguy opened this issue Sep 27, 2018 · 8 comments

Comments

@romainguy
Copy link

The glTF 2.0 specification is very vague on how alpha coverage should be supported. I do agree with what this phrase from the spec:

There is no perfect and fast solution that works for all cases.

I however believe that the spec could be more opinionated here. Here are several issues that could (and should IMO) be addressed by the spec:

  • There is no mention of premultiplied alpha vs non-premultiplied alpha (it's kind of implied by the mention of Porter-Duff SourceOver blending mode for the BLEND case, but it should be more explicitly described).
  • There is no mention of whether opacity is applied to specular lighting. In BLEND mode I think this should be explicitly disallowed.
  • If opacity doesn't affect specular lighting, a new alpha coverage mode ('FADE') should probably be added to have this capability. This can be useful for specific effects like fading an object in & out.
@MiiBond
Copy link
Contributor

MiiBond commented Sep 27, 2018

I believe that the term "alpha coverage" implies a simple over operator so lighting is not considered. i.e. it should currently work as a fade. This is why, I'd like an extension for simple optical transparency. See #1385
I agree that the spec should be more explicit about this though. I know the implementation in Babylon already doesn't treat this as pure alpha coverage (though, they've added an option to).

@emackey
Copy link
Member

emackey commented Sep 27, 2018

Some additional comments on blending modes are in #1033 and #822.

@emackey
Copy link
Member

emackey commented Sep 27, 2018

Specifically, BLEND mode is only for coverage, not transparency or translucency:

Use this mode for materials that simulate geometry such as gauze cloth or animal fur.

A gauze cloth with near-zero coverage would not have much if any specular reflection.

Proper support for transparency/translucency is being discussed in #1385, and generally the future of glTF materials is being brainstormed in #1442.

@romainguy
Copy link
Author

@MiiBond I saw #1385 before filing this but it goes much further than I intended with this issue. I'm also extremely interested in optical transparency though :)

@emackey It's what the spec says indeed but it seems to be used for transparency today, as there is no other way. I just read #822 and the discussion there is interesting. While I agree with the sentiment, the reality is that today glTF models use alpha coverage as transparency.

@donmccurdy
Copy link
Contributor

Some of this (premultiplied alpha, FADE mode) could perhaps be covered more explicitly in a possible KHR_blend extension.

@donmccurdy
Copy link
Contributor

There is no mention of premultiplied alpha vs non-premultiplied alpha

The spec does say, The stored texels [of baseColorTexture] must not be premultiplied. I'm not sure if I missed that before or if the clarification was added.

@romainguy
Copy link
Author

I don't remember seeing it before either. And does it mean the texture is not store premultiplied or that you should not alpha multiply the RGB channels during shading? And if so, why?

@lexaknyazev
Copy link
Member

The stored texels MUST NOT be premultiplied.

This sentence in the spec refers to the state in which the data is stored. I don't think that multiplication during shading is generally called "premultiplication".

Feel free to reopen if there are more clarifications needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants