Difference between revisions of "BlendAlphaMode"

(Created page)
 
m (Notes)
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
Different ways alpha affects color blending. See [[BlendMode]] and the [[BlendMode Formulas]] for additional notes.
 
Different ways alpha affects color blending. See [[BlendMode]] and the [[BlendMode Formulas]] for additional notes.
 
== Constants ==
 
== Constants ==
;alphamultiply: The alpha channel of what's drawn is multiplied with its RGB values. This is the default alpha mode.
+
;alphamultiply: The RGB values of what's drawn are multiplied by the alpha values of those colors during blending. This is the default alpha mode.
;premultiplied: The alpha channel of what's drawn is '''not''' multiplied with its RGB values ("premultiplied alpha blending"). This should generally be used when drawing a [[Canvas]] to the screen, for example, because the alpha values of the Canvas' texture had previously been multiplied with its RGB values when drawing content to the Canvas itself.
+
;premultiplied: The RGB values of what's drawn are '''not''' multiplied by the alpha values of those colors during blending. For most blend modes to work correctly with this alpha mode, the colors of a drawn object need to have had their RGB values multiplied by their alpha values at some point previously ("premultiplied alpha").
 
== Notes ==
 
== Notes ==
The "alphamultiply" constant does not affect the "multiply" [[BlendMode]]. Similarly, the "screen" [[BlendMode]]'s math is only correct if the "premultiplied" alpha mode is used and the alpha of drawn objects has already been multiplied with its RGB values previously (possibly inside a shader.)
+
The "premultiplied" constant should generally be used when drawing a [[Canvas]] to the screen, because the RGB values of the Canvas' texture had previously been multiplied by its alpha values when drawing content to the Canvas itself.
  
Several articles have been written about premultiplied alpha and when to use it:
+
The "alphamultiply" constant does not affect the "multiply" [[BlendMode]]. Similarly, the "screen" [[BlendMode]]'s math is only correct if the "premultiplied" alpha mode is used and the alpha of drawn objects has already been multiplied with its RGB values previously (possibly inside a shader).
  
 +
Several articles have been written about ''premultiplied alpha'' and when to use it:
 +
 +
* http://www.realtimerendering.com/blog/gpus-prefer-premultiplication/
 
* https://developer.nvidia.com/content/alpha-blending-pre-or-not-pre
 
* https://developer.nvidia.com/content/alpha-blending-pre-or-not-pre
 
* http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx
 
* http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx
 
* http://blogs.msdn.com/b/shawnhar/archive/2009/11/07/premultiplied-alpha-and-image-composition.aspx
 
* http://blogs.msdn.com/b/shawnhar/archive/2009/11/07/premultiplied-alpha-and-image-composition.aspx
 +
 
== See Also ==
 
== See Also ==
 
* [[parent::love.graphics]]
 
* [[parent::love.graphics]]

Latest revision as of 22:12, 11 January 2016

Available since LÖVE 0.10.0
This enum is not supported in earlier versions.

Different ways alpha affects color blending. See BlendMode and the BlendMode Formulas for additional notes.

Constants

alphamultiply
The RGB values of what's drawn are multiplied by the alpha values of those colors during blending. This is the default alpha mode.
premultiplied
The RGB values of what's drawn are not multiplied by the alpha values of those colors during blending. For most blend modes to work correctly with this alpha mode, the colors of a drawn object need to have had their RGB values multiplied by their alpha values at some point previously ("premultiplied alpha").

Notes

The "premultiplied" constant should generally be used when drawing a Canvas to the screen, because the RGB values of the Canvas' texture had previously been multiplied by its alpha values when drawing content to the Canvas itself.

The "alphamultiply" constant does not affect the "multiply" BlendMode. Similarly, the "screen" BlendMode's math is only correct if the "premultiplied" alpha mode is used and the alpha of drawn objects has already been multiplied with its RGB values previously (possibly inside a shader).

Several articles have been written about premultiplied alpha and when to use it:

See Also

Other Languages