分享

Understanding premultiplied alpha

 老匹夫 2019-10-22

I was always curious about what is happening during an alpha compositing process, especially how does premultiplied alpha in particular work. Mainly to completly understand the good use of blend factors, and be able to make really economic OpenGL shaders/render pipelines.

So I made a clarification of alpha blending, and have modelled the whole process in Photoshop, that uses only multiplication (Multiply), and addition (Linear Dodge) as blending mode only. Having this, it is really the same is happening in the Photoshop file what is being calculated on the GPU during alpha compositing, thus it can be observed from a really close view.

As I dig deeper, I found out that premultiplied alpha is mainly for “hardcode” alpha computation in advance, actually premultiply the alpha to not multiply at runtime on every frame. Without further expaination, you can follow the process below.

Understanding premultiplied alpha.

Click for a larger view, the notes are pretty self explanatory.

DISCLAIMER. THE INFORMATION ON THIS BLOG (INCLUDING BUT NOT LIMITED TO ARTICLES, IMAGES, CODE SNIPPETS, SOURCE CODES, EXAMPLE PROJECTS, ETC.) IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE INFORMATION ON THIS BLOG (INCLUDING BUT NOT LIMITED TO ARTICLES, IMAGES, CODE SNIPPETS, SOURCE CODES, EXAMPLE PROJECTS, ETC.).

Become a Patron! Tweet

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多