Control how textures are blended with the background when rendering. Setting a blend mode affects how the colors of a sprite or a game object are combined with the colors of the pixels behind them.
Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these reasons try to be careful about the construction of your Scene and the frequency in which blend modes are used.
WebGL and Canvas
'NORMAL'
, orPhaser.BlendModes.NORMAL
, or0
- Default setting and draws new shapes on top of the existing canvas content.
'ADD'
, orPhaser.BlendModes.ADD
, or1
- Where both shapes overlap the color is determined by adding color values.
'MULTIPLY'
, orPhaser.BlendModes.MULTIPLY
, or2
- The pixels are of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result.
'SCREEN'
, orPhaser.BlendModes.SCREEN
, or3
- The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply)
'ERASE'
, orPhaser.BlendModes.ERASE
, or17
- Alpha erase blend mode. Only works when rendering to a framebuffer, like a Render Texture
Canvas only
'OVERLAY'
, orPhaser.BlendModes.OVERLAY
, or4
- A combination of multiply and screen. Dark parts on the base layer become darker, and light parts become lighter.
'DARKEN'
, orPhaser.BlendModes.DARKEN
, or5
- Retains the darkest pixels of both layers.
'LIGHTEN'
, orPhaser.BlendModes.LIGHTEN
, or6
- Retains the lightest pixels of both layers.
'COLOR_DODGE'
, orPhaser.BlendModes.COLOR_DODGE
, or7
- Divides the bottom layer by the inverted top layer.
'COLOR_BURN'
, orPhaser.BlendModes.COLOR_BURN
, or8
- Divides the inverted bottom layer by the top layer, and then inverts the result.
'HARD_LIGHT'
, orPhaser.BlendModes.HARD_LIGHT
, or9
- A combination of multiply and screen like overlay, but with top and bottom layer swapped.
'SOFT_LIGHT'
, orPhaser.BlendModes.SOFT_LIGHT
, or10
- A softer version of hard-light. Pure black or white does not result in pure black or white.
'DIFFERENCE'
, orPhaser.BlendModes.DIFFERENCE
, or11
- Subtracts the bottom layer from the top layer or the other way round to always get a positive value.
'EXCLUSION'
, orPhaser.BlendModes.EXCLUSION
, or12
- Like difference, but with lower contrast.
'HUE'
, orPhaser.BlendModes.HUE
, or13
- Preserves the luma and chroma of the bottom layer, while adopting the hue of the top layer.
'SATURATION'
, orPhaser.BlendModes.SATURATION
, or14
- Preserves the luma and hue of the bottom layer, while adopting the chroma of the top layer.
'COLOR'
, orPhaser.BlendModes.COLOR
, or15
- Preserves the luma of the bottom layer, while adopting the hue and chroma of the top layer.
'LUMINOSITY'
, orPhaser.BlendModes.LUMINOSITY
, or16
- Preserves the hue and chroma of the bottom layer, while adopting the luma of the top layer.
'SOURCE_IN'
, orPhaser.BlendModes.SOURCE_IN
, or18
- The new shape is drawn only where both the new shape and the destination canvas overlap. Everything else is made transparent.
'SOURCE_OUT'
, orPhaser.BlendModes.SOURCE_OUT
, or19
- The new shape is drawn where it doesn't overlap the existing canvas content.
'SOURCE_ATOP'
, orPhaser.BlendModes.SOURCE_ATOP
, or20
- The new shape is only drawn where it overlaps the existing canvas content.
'DESTINATION_OVER'
, orPhaser.BlendModes.DESTINATION_OVER
, or21
- New shapes are drawn behind the existing canvas content.
'DESTINATION_IN'
, orPhaser.BlendModes.DESTINATION_IN
, or22
- The existing canvas content is kept where both the new shape and existing canvas content overlap. Everything else is made transparent.
'DESTINATION_OUT'
, orPhaser.BlendModes.DESTINATION_OUT
, or23
- The existing content is kept where it doesn't overlap the new shape.
'DESTINATION_ATOP'
, orPhaser.BlendModes.DESTINATION_ATOP
, or24
- The existing canvas is only kept where it overlaps the new shape. The new shape is drawn behind the canvas content.
'LIGHTER'
, orPhaser.BlendModes.LIGHTER
, or25
- Where both shapes overlap the color is determined by adding color values.
'COPY'
, orPhaser.BlendModes.COPY
, or26
- Only the new shape is shown.
'XOR'
, orPhaser.BlendModes.XOR
, or27
- Shapes are made transparent where both overlap and drawn normal everywhere else.
Author Credits
Content on this page includes work by: