Fix #120213: GPv3: Tint modifier not working correctly
The GPv3 tint modifier will give incorrect result in fill tint due to two reasons: 1) The material index being wrong; 2) The default value for `fill_color` attribute needs to be explicitly assigned as `ColorGeometry4f(float4(0.0f))` to ensure correct color mixing and switching between fill/material color in the tint modifier. Pull Request: https://projects.blender.org/blender/blender/pulls/120249
This commit is contained in:
parent
b0bebd6265
commit
022e46a7e2
|
@ -411,7 +411,11 @@ void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf,
|
|||
SpanAttributeWriter<float> stroke_point_aspect_ratios =
|
||||
attributes.lookup_or_add_for_write_span<float>("aspect_ratio", AttrDomain::Curve);
|
||||
SpanAttributeWriter<ColorGeometry4f> stroke_fill_colors =
|
||||
attributes.lookup_or_add_for_write_span<ColorGeometry4f>("fill_color", AttrDomain::Curve);
|
||||
attributes.lookup_or_add_for_write_span<ColorGeometry4f>(
|
||||
"fill_color",
|
||||
AttrDomain::Curve,
|
||||
bke::AttributeInitVArray(VArray<ColorGeometry4f>::ForSingle(
|
||||
ColorGeometry4f(float4(0.0f)), curves.curves_num())));
|
||||
SpanAttributeWriter<int> stroke_materials = attributes.lookup_or_add_for_write_span<int>(
|
||||
"material_index", AttrDomain::Curve);
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ static void modify_stroke_color(Object &ob,
|
|||
|
||||
/* Common input color and base factor calculation. */
|
||||
auto get_material_color = [&](const int64_t curve_i) {
|
||||
const Material *ma = BKE_object_material_get(&ob, stroke_materials[curve_i]);
|
||||
const Material *ma = BKE_object_material_get(&ob, stroke_materials[curve_i] + 1);
|
||||
const MaterialGPencilStyle *gp_style = ma ? ma->gp_style : nullptr;
|
||||
return (gp_style ? ColorGeometry4f(gp_style->stroke_rgba) :
|
||||
ColorGeometry4f(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
|
@ -256,8 +256,11 @@ static void modify_fill_color(Object &ob,
|
|||
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
|
||||
/* Fill color per stroke. */
|
||||
bke::SpanAttributeWriter<ColorGeometry4f> fill_colors =
|
||||
attributes.lookup_or_add_for_write_span<ColorGeometry4f>("fill_color",
|
||||
bke::AttrDomain::Curve);
|
||||
attributes.lookup_or_add_for_write_span<ColorGeometry4f>(
|
||||
"fill_color",
|
||||
bke::AttrDomain::Curve,
|
||||
bke::AttributeInitVArray(VArray<ColorGeometry4f>::ForSingle(
|
||||
ColorGeometry4f(float4(0.0f)), curves.curves_num())));
|
||||
const VArray<int> stroke_materials = *attributes.lookup_or_default<int>(
|
||||
"material_index", bke::AttrDomain::Curve, 0);
|
||||
const VArray<float> vgroup_weights = modifier::greasepencil::get_influence_vertex_weights(
|
||||
|
@ -265,7 +268,7 @@ static void modify_fill_color(Object &ob,
|
|||
|
||||
/* Common input color and base factor calculation. */
|
||||
auto get_material_color = [&](const int64_t curve_i) {
|
||||
const Material *ma = BKE_object_material_get(&ob, stroke_materials[curve_i]);
|
||||
const Material *ma = BKE_object_material_get(&ob, stroke_materials[curve_i] + 1);
|
||||
const MaterialGPencilStyle *gp_style = ma ? ma->gp_style : nullptr;
|
||||
return (gp_style ? ColorGeometry4f(gp_style->fill_rgba) :
|
||||
ColorGeometry4f(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
|
|
Loading…
Reference in New Issue