mirror of
https://projects.blender.org/blender/blender.git
synced 2025-01-22 07:22:12 -05:00
Fix: Grease pencil inconsistent inverting of influence vertex groups
Behavior was not consistent across modifiers - Opacity -- strokes were using inverted weights only when MOD_GREASE_PENCIL_OPACITY_USE_WEIGHT_AS_FACTOR was OFF, fills however when MOD_GREASE_PENCIL_OPACITY_USE_WEIGHT_AS_FACTOR was ON - Tint -- strokes and fills were using inverted weights only when MOD_GREASE_PENCIL_TINT_USE_WEIGHT_AS_FACTOR was ON - others (Envelope, Lattice, Noise, Offset ) were ignoring inverting the influence vertex group alltogether (but that is reported in #133055 and will be handled separately, see below) - others (Hook, ... ) were always inverting it, which is correct This pull requeset only corrects this for Opacity and Tint (in the way that now weights are always inverted, no matter if "Use Weight As Factor" is used). This also paves the way to a more general fix for #133055 (which intends to move the weight inversion to the very general greasepencil::get_influence_vertex_weights) Pull Request: https://projects.blender.org/blender/blender/pulls/133310
This commit is contained in:
parent
71d3e32974
commit
00968fe6db
2 changed files with 13 additions and 14 deletions
|
@ -89,7 +89,8 @@ static void modify_stroke_color(const GreasePencilOpacityModifierData &omd,
|
|||
curves_mask.foreach_index(GrainSize(512), [&](const int64_t curve_i) {
|
||||
const IndexRange points = points_by_curve[curve_i];
|
||||
for (const int64_t point_i : points) {
|
||||
const float vgroup_weight = vgroup_weights[point_i];
|
||||
const float vgroup_weight = invert_vertex_group ? 1.0f - vgroup_weights[point_i] :
|
||||
vgroup_weights[point_i];
|
||||
if (vgroup_weight <= 0.0f) {
|
||||
continue;
|
||||
}
|
||||
|
@ -110,9 +111,8 @@ static void modify_stroke_color(const GreasePencilOpacityModifierData &omd,
|
|||
}
|
||||
else {
|
||||
/* Use vertex group weights as influence factors. */
|
||||
const float vgroup_influence = invert_vertex_group ? 1.0f - vgroup_weight : vgroup_weight;
|
||||
opacities.span[point_i] = std::clamp(
|
||||
opacities.span[point_i] + (omd.color_factor * curve_factor - 1.0f) * vgroup_influence,
|
||||
opacities.span[point_i] + (omd.color_factor * curve_factor - 1.0f) * vgroup_weight,
|
||||
0.0f,
|
||||
1.0f);
|
||||
}
|
||||
|
@ -144,17 +144,15 @@ static void modify_fill_color(const GreasePencilOpacityModifierData &omd,
|
|||
/* Use the first stroke point as vertex weight. */
|
||||
const IndexRange points = points_by_curve[curve_i];
|
||||
const float vgroup_weight_first = vgroup_weights[points.first()];
|
||||
float stroke_weight = vgroup_weight_first;
|
||||
float stroke_weight = invert_vertex_group ? 1.0f - vgroup_weight_first : vgroup_weight_first;
|
||||
if (use_vgroup_opacity) {
|
||||
if (points.is_empty() || (vgroup_weight_first <= 0.0f)) {
|
||||
if (points.is_empty() || (stroke_weight <= 0.0f)) {
|
||||
stroke_weight = 1.0f;
|
||||
}
|
||||
const float stroke_influence = invert_vertex_group ? 1.0f - stroke_weight : stroke_weight;
|
||||
|
||||
fill_opacities.span[curve_i] = std::clamp(stroke_influence, 0.0f, 1.0f);
|
||||
fill_opacities.span[curve_i] = std::clamp(stroke_weight, 0.0f, 1.0f);
|
||||
}
|
||||
else {
|
||||
if (!points.is_empty() && (vgroup_weight_first > 0.0f)) {
|
||||
if (!points.is_empty() && (stroke_weight > 0.0f)) {
|
||||
fill_opacities.span[curve_i] = std::clamp(omd.color_factor * stroke_weight, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,9 +187,10 @@ static void modify_stroke_color(Object &ob,
|
|||
};
|
||||
|
||||
auto get_point_factor = [&](const int64_t point_i) {
|
||||
const float weight = vgroup_weights[point_i];
|
||||
const float weight = invert_vertex_group ? 1.0f - vgroup_weights[point_i] :
|
||||
vgroup_weights[point_i];
|
||||
if (use_weight_as_factor) {
|
||||
return invert_vertex_group ? 1.0f - weight : weight;
|
||||
return weight;
|
||||
}
|
||||
return tmd.factor * weight;
|
||||
};
|
||||
|
@ -275,12 +276,12 @@ static void modify_fill_color(Object &ob,
|
|||
/* Use the first stroke point as vertex weight. */
|
||||
const IndexRange points = points_by_curve[curve_i];
|
||||
const float vgroup_weight_first = vgroup_weights[points.first()];
|
||||
float stroke_weight = vgroup_weight_first;
|
||||
if (points.is_empty() || (vgroup_weight_first <= 0.0f)) {
|
||||
float stroke_weight = invert_vertex_group ? 1.0f - vgroup_weight_first : vgroup_weight_first;
|
||||
if (points.is_empty() || (stroke_weight <= 0.0f)) {
|
||||
return 0.0f;
|
||||
}
|
||||
else if (use_weight_as_factor) {
|
||||
return invert_vertex_group ? 1.0f - stroke_weight : stroke_weight;
|
||||
return stroke_weight;
|
||||
}
|
||||
return tmd.factor * stroke_weight;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue