Types/BlendMode: Difference between revisions
(Split into own page) |
(Clarify formula for normal blending.) |
||
Line 1: | Line 1: | ||
A [[Types/string]] that determines how sprites/animations should blend with the background. The possible values are listed below. | A [[Types/string]] that determines how sprites/animations should blend with the background. The possible values are listed below. | ||
Note: | Note: In most of Factorio it is assumed colors are in alpha premultiplied format: [https://www.factorio.com/blog/post/fff-172 FFF #172 - Blending and Rendering]. Sprites get premultiplied when loaded, unless <code>premul_alpha</code> is set to false on the sprite/animation itself. But generating mipmaps doesn't respect <code>premul_alpha</code>, so lowel mipmap levels will be in premultiplied format regardless. | ||
== Possible values == | == Possible values == | ||
=== normal === | === normal === | ||
The result color is determined with the following formula: | The result color is determined with the following formula: | ||
<code>Result = Active_RGB | <code>Result = Active_RGB + Background_RGB * ( 1 - Active_Alpha )</code> | ||
Note: This is alpha blending with an assumption that Active_RGB is already premultiplied with Active_Alpha. | |||
=== additive === | === additive === |
Revision as of 12:48, 22 January 2023
A Types/string that determines how sprites/animations should blend with the background. The possible values are listed below.
Note: In most of Factorio it is assumed colors are in alpha premultiplied format: FFF #172 - Blending and Rendering. Sprites get premultiplied when loaded, unless premul_alpha
is set to false on the sprite/animation itself. But generating mipmaps doesn't respect premul_alpha
, so lowel mipmap levels will be in premultiplied format regardless.
Possible values
normal
The result color is determined with the following formula:
Result = Active_RGB + Background_RGB * ( 1 - Active_Alpha )
Note: This is alpha blending with an assumption that Active_RGB is already premultiplied with Active_Alpha.
additive
The result color is determined with the following formula:
Result = Active_RGB + Background_RGB
additive-soft
The result color is determined with the following formula:
Result = Active_RGB * ( 1 - Background_RGB ) + Background_RGB
multiplicative
The result color is determined with the following formula:
Result = Active_RGB * Background_RGB
overwrite
The result color is determined with the following formula:
Result = Active_RGBA or Background_RGBA