← Back to team overview

dx-packages team mailing list archive

[Bug 706863] Re: Switch to premultiplied alpha blending

 

** Changed in: unity (Ubuntu)
       Status: New => Fix Released

-- 
You received this bug notification because you are a member of DX
Packages, which is subscribed to unity in Ubuntu.
Matching subscriptions: dx-packages
https://bugs.launchpad.net/bugs/706863

Title:
  Switch to premultiplied alpha blending

Status in Unity:
  Fix Released
Status in “unity” package in Ubuntu:
  Fix Released

Bug description:
  Premultiplied alpha blending is the standard way of compositing
  digital images. Porter and Duff, who are mostly known for having fully
  developed the process of compositing, have actually defined their
  compositing operators in terms of premultiplied components [1].
  Premultiplied alpha has a lot of advantages over the way people tend
  to use blending nowadays in (hardware accelerated) real-time
  rendering. One of them is that with non-premultiplied alpha, 5 of the
  Porter-Duff operators can't be defined (DST_OVER, SRC_IN, SRC_ATOP,
  DST_ATOP, SRC_XOR), even with a separate alpha function. Another is
  that with non-premultiplied alpha, using bilinear filtering for
  texture magnifications generates color bleeding issues [2].

  Unity currently only uses the SRC_OVER operator for blending two types
  of sources, the non-premultiplied ones coming from GdkPixbuf, and the
  premultiplied ones coming from Cairo. The patch I propose
  premultiplies the sources loaded by GdkPixbuf, unifying the way alpha
  blending is done in Unity. It makes it easier to define the blend
  operation by removing the current need of separating the color and
  alpha functions.

  Another important point for premultiplied alpha in Unity is that
  rendertarget (FBO) composition is fundamentally impossible using non-
  premultiplied alpha [3]. That could explain some of the blending
  issues that have been seen so far (we are currently using
  rendertargets). Note that for this exact same reason, the XComposite
  extension specification requires premultiplied drawables.

  For more informations on the subject, see this nice blog post [4].

  Once the Unity code is adapted, it would also be nice to have a helper
  function to simply define the blending state using a Porter-Duff
  operator enumeration.

  
  [1] http://graphics.pixar.com/library/Compositing/paper.pdf 
  [2] http://www.youtube.com/watch?v=dU9AXzCabiM
  [3] http://blogs.msdn.com/b/shawnhar/archive/2009/11/07/premultiplied-alpha-and-image-composition.aspx
  [4] http://blogs.msdn.com/b/shawnhar/archive/2010/04/09/how-shawn-learned-to-stop-worrying-and-love-premultiplied-alpha.aspx

To manage notifications about this bug go to:
https://bugs.launchpad.net/unity/+bug/706863/+subscriptions