add difference blending mode, also fix error in last commit

This commit is contained in:
Campbell Barton 2012-07-18 13:44:48 +00:00
parent 73a778a4d0
commit c0e004bd61
3 changed files with 12 additions and 7 deletions

View File

@ -1235,6 +1235,9 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x
case MASK_BLEND_REPLACE:
value = (value * (1.0f - layer->alpha)) + (value_layer * layer->alpha);
break;
case MASK_BLEND_DIFFERENCE:
value = fabsf(value - value_layer);
break;
default: /* same as add */
BLI_assert(0);
value += value_layer;
@ -1243,7 +1246,7 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x
/* clamp after applying each layer so we don't get
* issues subtracting after accumulating over 1.0f */
return CLAMPIS(value, 0.0f, 1.0f);
CLAMP(value, 0.0f, 1.0f);
}
return value;

View File

@ -167,12 +167,13 @@ enum {
/* masklay->blend */
enum {
MASK_BLEND_ADD = 0,
MASK_BLEND_SUBTRACT = 1,
MASK_BLEND_LIGHTEN = 2,
MASK_BLEND_DARKEN = 3,
MASK_BLEND_MUL = 4,
MASK_BLEND_REPLACE = 5,
MASK_BLEND_ADD = 0,
MASK_BLEND_SUBTRACT = 1,
MASK_BLEND_LIGHTEN = 2,
MASK_BLEND_DARKEN = 3,
MASK_BLEND_MUL = 4,
MASK_BLEND_REPLACE = 5,
MASK_BLEND_DIFFERENCE = 6
};
/* masklay->blend_flag */

View File

@ -585,6 +585,7 @@ static void rna_def_mask_layer(BlenderRNA *brna)
{MASK_BLEND_DARKEN, "DARKEN", 0, "Darken", ""},
{MASK_BLEND_MUL, "MUL", 0, "Multiply", ""},
{MASK_BLEND_REPLACE, "REPLACE", 0, "Replace", ""},
{MASK_BLEND_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""},
{0, NULL, 0, NULL, NULL}
};