Difference between revisions of "BlendAlphaMode"

(Created page)
 
m
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 "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.)
 
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.)
  

Revision as of 20:55, 16 December 2015

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