Opacity modifier implementation based on GP2. Functionality is largely unchanged. _Color Mode_ is either `Stroke` or `Fill` for modifying color opacity or `Hardness`. _Uniform Opacity_ does two things at once (!): - Sets the same opacity value for every point in a stroke. - Sets opacity as an absolute value rather than a factor. _Weight as Factor_ (button to the right of Opacity Factor): Use the vertex group as opacity __factor__ rather than an overall __influence__. This is confusing and hard to convey, but copies behavior from GP2. The _Influence_ panel contains the same filter settings as the GP2 modifier, with some small changes: - _Layer_ selects only strokes in the respective layer (with an _Invert_ option) - _Material_ selects only points with the respective material (with an _Invert_ option) - _Layer Pass_ and _Material Pass_ select only strokes/points which are rendered in the respective pass. _Note 1: Layers don't have UI for setting a pass yet, this will be a generic layer attribute. This can be set through the API for testing._ _Note 2: In GP2 a pass value of zero was used to disable pass filters. Since zero is a valid pass ID an explicit flag has been added for the purpose of turning pass filters on and off._ - _Vertex Group_: This can be used as an additional influence filter on points. If _Weight as Factor_ is enable the vertex group instead replaces the opacity factor. In _Fill_ mode the vertex group weight of the stroke's first point is used as influence for the entire stroke. - _Custom Curve_ is another possible influence factor per point. The curve input value is the relative position of a point along its stroke. The Influence settings have been moved into a separate DNA struct, which should help with reusability in various modifiers. Various utility functions can be found int `MOD_grease_pencil_util.hh` for handling influence settings and generating `IndexMasks` for modernized C++ code. Pull Request: https://projects.blender.org/blender/blender/pulls/116946
67 lines
2.6 KiB
C++
67 lines
2.6 KiB
C++
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup modifiers
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "BLI_index_mask.hh"
|
|
#include "BLI_vector.hh"
|
|
|
|
#include "BKE_modifier.hh"
|
|
|
|
struct ARegionType;
|
|
struct bContext;
|
|
struct GreasePencil;
|
|
struct GreasePencilModifierInfluenceData;
|
|
struct GreasePencilModifierLayerFilter;
|
|
struct GreasePencilModifierMaterialFilter;
|
|
struct PanelType;
|
|
struct PointerRNA;
|
|
struct uiLayout;
|
|
namespace blender::bke {
|
|
class CurvesGeometry;
|
|
namespace greasepencil {
|
|
class Drawing;
|
|
}
|
|
} // namespace blender::bke
|
|
|
|
namespace blender::modifier::greasepencil {
|
|
|
|
void init_influence_data(GreasePencilModifierInfluenceData *influence_data, bool has_custom_curve);
|
|
void copy_influence_data(const GreasePencilModifierInfluenceData *influence_data_src,
|
|
GreasePencilModifierInfluenceData *influence_data_dst,
|
|
int flag);
|
|
void free_influence_data(GreasePencilModifierInfluenceData *influence_data);
|
|
void foreach_influence_ID_link(GreasePencilModifierInfluenceData *influence_data,
|
|
Object *ob,
|
|
IDWalkFunc walk,
|
|
void *user_data);
|
|
void write_influence_data(BlendWriter *writer,
|
|
const GreasePencilModifierInfluenceData *influence_data);
|
|
void read_influence_data(BlendDataReader *reader,
|
|
GreasePencilModifierInfluenceData *influence_data);
|
|
|
|
void draw_layer_filter_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr);
|
|
void draw_material_filter_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr);
|
|
void draw_vertex_group_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr);
|
|
void draw_custom_curve_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr);
|
|
|
|
IndexMask get_filtered_layer_mask(const GreasePencil &grease_pencil,
|
|
const GreasePencilModifierInfluenceData &influence_data,
|
|
IndexMaskMemory &memory);
|
|
|
|
IndexMask get_filtered_stroke_mask(const Object *ob,
|
|
const bke::CurvesGeometry &curves,
|
|
const GreasePencilModifierInfluenceData &influence_data,
|
|
IndexMaskMemory &memory);
|
|
|
|
Vector<bke::greasepencil::Drawing *> get_drawings_for_write(GreasePencil &grease_pencil,
|
|
const IndexMask &layer_mask,
|
|
int frame);
|
|
|
|
} // namespace blender::modifier::greasepencil
|