Difference between revisions of "BlendMode"

(I reckon it makes sense to have the formulas on the BlendMode page. But uh, someone might want to fix to up my formatting. :P)
(Undoing the terrible format. Try again with a better look.)
Line 1: Line 1:
 
{{newin|[[0.2.0]]|020|type=enum}}
 
{{newin|[[0.2.0]]|020|type=enum}}
How what is drawn is blended with what's already there.
+
Different ways you do alpha blending.
 
 
The numbers in the formulas are in the interval [0,1]. The resulting color is clamped to [0,1] (except when rendering to HDR [[Canvas]]es).
 
 
 
<tt>dst</tt> is the existing color.
 
 
 
<tt>src</tt> is the new color.
 
 
 
<tt>res</tt> is the resulting color.
 
 
== Constants ==
 
== Constants ==
;additive
+
;additive: Additive blend mode.
    res.rgba = dst.rgba + (src.rgba * src.a)
+
;alpha: Alpha blend mode ('normal').
;alpha: The default blend mode.
 
 
 
    res.rgb = dst.rgb * (1 - src.a) + src.rgb * src.a
 
    res.a = dst.a * (1 - src.a) + src.a
 
 
 
    Before 0.9.0:
 
    res.rgba = dst.rgba * (1 - src.a) + src.rgba * src.a
 
 
 
 
{{newin|[[0.7.0]]|070|type=following choices|plural=y}}
 
{{newin|[[0.7.0]]|070|type=following choices|plural=y}}
;subtractive
+
;subtractive: Subtractive blend mode.
    res.rgba = dst.rgba - src.rgba * src.a
+
;multiplicative: Multiply blend mode.
;multiplicative
 
    res.r = src.r * dst.r
 
 
 
    Before 0.9.0:
 
    res.rgba = dst.rgba * (1 - src.a) + src.rgba * dst.rgba
 
 
{{newin|[[0.8.0]]|080|type=following choice}}
 
{{newin|[[0.8.0]]|080|type=following choice}}
;premultiplied
+
;premultiplied: Premultiplied blend mode.
    res.rgba = dst.rgba * (1 - src.a) + src.rgba
 
 
{{newin|[[0.9.0]]|090|type=following choice}}
 
{{newin|[[0.9.0]]|090|type=following choice}}
;replace
+
;replace: Replace blend mode.
    res.rgba = src.rgba
 
 
== See Also ==
 
== See Also ==
 
* [[parent::love.graphics]]
 
* [[parent::love.graphics]]

Revision as of 04:14, 22 June 2013

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

Different ways you do alpha blending.

Constants

additive
Additive blend mode.
alpha
Alpha blend mode ('normal').
Available since LÖVE 0.7.0
These following choices are not supported in earlier versions.
subtractive
Subtractive blend mode.
multiplicative
Multiply blend mode.
Available since LÖVE 0.8.0
This following choice is not supported in earlier versions.
premultiplied
Premultiplied blend mode.
Available since LÖVE 0.9.0
This following choice is not supported in earlier versions.
replace
Replace blend mode.

See Also

Other Languages