diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-15 07:11:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-15 07:11:07 +0400 |
commit | 02bac0bebfcf7f56d5ff7f04a122ec8144424e3d (patch) | |
tree | c44da5b2b51db5033cc57ec8d62ca8d2aaf84fb3 /source/blender/blenkernel | |
parent | 7cc5af4ef3869f6a1d2766eb5643f94e2f540cfa (diff) |
falloff option for mask layers
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/mask_rasterize.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index cd3b6c71c09..b415e9f1ba8 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -32,6 +32,7 @@ #include "DNA_vec_types.h" #include "DNA_mask_types.h" +#include "DNA_scene_types.h" #include "BLI_utildefines.h" #include "BLI_scanfill.h" @@ -93,6 +94,7 @@ typedef struct MaskRasterLayer { float alpha; char blend; char blend_flag; + char falloff; } MaskRasterLayer; @@ -832,6 +834,7 @@ void BLI_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas layer->alpha = masklay->alpha; layer->blend = masklay->blend; layer->blend_flag = masklay->blend_flag; + layer->falloff = masklay->falloff; } /* printf("tris %d, feather tris %d\n", sf_tri_tot, tot_feather_quads); */ @@ -976,11 +979,29 @@ float BLI_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x float value_layer; if (BLI_in_rctf_v(&layer->bounds, xy)) { - const float dist = 1.0f - layer_bucket_depth_from_xy(layer, xy); - const float dist_ease = (3.0f * dist * dist - 2.0f * dist * dist * dist); + float val = 1.0f - layer_bucket_depth_from_xy(layer, xy); + + switch (layer->falloff) { + case PROP_SMOOTH: + /* ease - gives less hard lines for dilate/erode feather */ + val = (3.0f * val * val - 2.0f * val * val * val); + break; + case PROP_SPHERE: + val = sqrtf(2.0f * val - val * val); + break; + case PROP_ROOT: + val = sqrtf(val); + break; + case PROP_SHARP: + val = val * val; + break; + case PROP_LIN: + default: + /* nothing */ + break; + } - /* apply alpha */ - value_layer = dist_ease * layer->alpha; + value_layer = val * layer->alpha; } else { value_layer = 0.0f; |