When GameMaker goes to draw a pixel there is a source colour (the colour of the pixel we're going to draw) and a destination colour (the colour that's already in the pixel we're drawing to), so the source and destination colours need to be processed to create the final pixel value.
After the source and destination pixels are multiplied by the set factors, those two pixels now need to be mixed together to generate the final pixel value. By default, they are added together, meaning the final pixel is formed as: (source * factor) + (destination * factor).
With this function, you can change how the final pixel is calculated from the source and destination, and you can choose between the following equations:
Blend Mode Equation Constant | ||
---|---|---|
Constant | Description | Equation |
bm_eq_add | Add both together (the default equation). | source + destination |
bm_eq_subtract | Subtract source from destination. | destination - source |
bm_eq_reverse_subtract | Subtract destination from source. | source - destination |
bm_eq_min | Use whichever value is smaller. | min(source, destination) |
bm_eq_max | Use whichever value is larger. | max(source, destination) |
IMPORTANT Blend factors are not applied when bm_eq_min or bm_eq_max is used as the blend equation, which is effectively the same as using bm_one as the factors.
You can set different equations for the colour components (RGB) and the alpha component separately by calling gpu_set_blendequation_sepalpha.
To help you get the most from blend modes and to help understand how they work and how they affect the final image being drawn to the screen, we recommend that you read the following guide:
gpu_set_blendequation(equation);
Argument | Type | Description |
---|---|---|
equation | Blend Mode Equation Constant | Blend mode equation (see constants above). |
N/A
gpu_set_blendmode_ext(bm_src_alpha, bm_one);
gpu_set_blendequation(bm_subtract);
draw_circle(100, 100, 50, 0);
gpu_set_blendmode(bm_normal);
This changes the blend mode factors and then the equation, draws a circle and resets both the blend mode factors and equation (by switching to the normal blend mode) so they don't affect things drawn after this.
The blending here will function as the following: it will multiply the source pixel with the source alpha, and the destination pixel with 1 (keeping it the same as it was). It will then subtract the source from the destination.