Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2020-03-13 12:28:30 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-03-13 12:28:59 +0300
commitde9c7bae7b9e7c66584531953c5acae274c013c2 (patch)
tree737bb6e21a171f636ae2ae8d1fbeb2afb82f93b9
parentdf032580c170d9f5e508b34673b84a14f8808990 (diff)
GPencil: Join Tint and Vertex Color modifier
Both are doing almost the same and can be merged. This reduce complexity for user and less code to maintain. Reviewed By: mendio, pepeland, fclem Differential Revision: https://developer.blender.org/D7134
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py51
-rw-r--r--source/blender/blenloader/intern/readfile.c12
-rw-r--r--source/blender/blenloader/intern/versioning_280.c21
-rw-r--r--source/blender/blenloader/intern/writefile.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c3
-rw-r--r--source/blender/gpencil_modifiers/CMakeLists.txt1
-rw-r--r--source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h1
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c1
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c233
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c314
-rw-r--r--source/blender/makesdna/DNA_gpencil_modifier_types.h67
-rw-r--r--source/blender/makesrna/intern/rna_gpencil_modifier.c226
12 files changed, 320 insertions, 620 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 99508bf8fab..bcf1c285d2b 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1891,16 +1891,34 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
self.gpencil_masking(layout, ob, md, True, True)
def GP_TINT(self, layout, ob, md):
- split = layout.split()
+ layout.row().prop(md, "tint_type", expand=True)
- col = split.column()
- col.prop(md, "color")
- col.prop(md, "factor")
+ if md.tint_type == 'UNIFORM':
+ col = layout.column()
+ col.prop(md, "color")
- row = layout.row()
- row.prop(md, "modify_color")
+ col.separator()
+ col.prop(md, "factor")
- self.gpencil_masking(layout, ob, md, False, True)
+ if md.tint_type == 'GRADIENT':
+ col = layout.column()
+ col.label(text="Colors:")
+ col.template_color_ramp(md, "colors")
+
+ col.separator()
+
+ col.label(text="Object:")
+ col.prop(md, "object", text="")
+
+ col.separator()
+ row = col.row(align=True)
+ row.prop(md, "radius")
+ row.prop(md, "factor")
+
+ col.separator()
+ col.prop(md, "vertex_mode")
+
+ self.gpencil_masking(layout, ob, md, True, True)
def GP_TIME(self, layout, ob, md):
gpd = ob.data
@@ -2165,25 +2183,6 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
self.gpencil_masking(layout, ob, md, False)
- def GP_VERTEXCOLOR(self, layout, ob, md):
- col = layout.column()
- col.label(text="Object:")
- col.prop(md, "object", text="")
-
- col.separator()
- row = col.row(align=True)
- row.prop(md, "radius")
- row.prop(md, "factor", text="Strength", slider=True)
-
- col.separator()
- col.label(text="Colors:")
- col.template_color_ramp(md, "colors")
-
- col.separator()
- col.prop(md, "vertex_mode")
-
- self.gpencil_masking(layout, ob, md, True, True)
-
classes = (
DATA_PT_modifiers,
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 49b51c34562..dadae3a938a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5774,8 +5774,8 @@ static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb)
BKE_curvemapping_initialize(gpmd->curve_thickness);
}
}
- else if (md->type == eGpencilModifierType_Vertexcolor) {
- VertexcolorGpencilModifierData *gpmd = (VertexcolorGpencilModifierData *)md;
+ else if (md->type == eGpencilModifierType_Tint) {
+ TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
gpmd->colorband = newdataadr(fd, gpmd->colorband);
gpmd->curve_intensity = newdataadr(fd, gpmd->curve_intensity);
if (gpmd->curve_intensity) {
@@ -5799,14 +5799,6 @@ static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb)
BKE_curvemapping_initialize(gpmd->curve_intensity);
}
}
- else if (md->type == eGpencilModifierType_Tint) {
- TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
- gpmd->curve_intensity = newdataadr(fd, gpmd->curve_intensity);
- if (gpmd->curve_intensity) {
- direct_link_curvemapping(fd, gpmd->curve_intensity);
- BKE_curvemapping_initialize(gpmd->curve_intensity);
- }
- }
else if (md->type == eGpencilModifierType_Opacity) {
OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
gpmd->curve_intensity = newdataadr(fd, gpmd->curve_intensity);
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index d0659bfd34c..7d727e81882 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1068,8 +1068,8 @@ static void do_version_curvemapping_walker(Main *bmain, void (*callback)(CurveMa
callback(gpmd->curve_intensity);
}
}
- else if (md->type == eGpencilModifierType_Vertexcolor) {
- VertexcolorGpencilModifierData *gpmd = (VertexcolorGpencilModifierData *)md;
+ else if (md->type == eGpencilModifierType_Tint) {
+ TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
if (gpmd->curve_intensity) {
callback(gpmd->curve_intensity);
@@ -1096,13 +1096,6 @@ static void do_version_curvemapping_walker(Main *bmain, void (*callback)(CurveMa
callback(gpmd->curve_intensity);
}
}
- else if (md->type == eGpencilModifierType_Tint) {
- TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
-
- if (gpmd->curve_intensity) {
- callback(gpmd->curve_intensity);
- }
- }
}
}
@@ -4728,16 +4721,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
break;
}
- case eGpencilModifierType_Vertexcolor: {
- VertexcolorGpencilModifierData *mmd = (VertexcolorGpencilModifierData *)md;
- if (mmd->curve_intensity == NULL) {
- mmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- if (mmd->curve_intensity) {
- BKE_curvemapping_initialize(mmd->curve_intensity);
- }
- }
- break;
- }
default:
break;
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index a9c5008062b..a92404b2372 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1844,8 +1844,8 @@ static void write_gpencil_modifiers(WriteData *wd, ListBase *modbase)
write_curvemapping(wd, gpmd->curfalloff);
}
}
- else if (md->type == eGpencilModifierType_Vertexcolor) {
- VertexcolorGpencilModifierData *gpmd = (VertexcolorGpencilModifierData *)md;
+ else if (md->type == eGpencilModifierType_Tint) {
+ TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
if (gpmd->colorband) {
writestruct(wd, DATA, ColorBand, 1, gpmd->colorband);
}
@@ -1871,12 +1871,6 @@ static void write_gpencil_modifiers(WriteData *wd, ListBase *modbase)
write_curvemapping(wd, gpmd->curve_intensity);
}
}
- else if (md->type == eGpencilModifierType_Tint) {
- TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
- if (gpmd->curve_intensity) {
- write_curvemapping(wd, gpmd->curve_intensity);
- }
- }
}
}
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 3e88a7a7b88..1b34f85f800 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2252,9 +2252,6 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
case eGpencilModifierType_Armature:
data.icon = ICON_MOD_ARMATURE;
break;
- case eGpencilModifierType_Vertexcolor:
- data.icon = ICON_MOD_NORMALEDIT;
- break;
/* Default */
default:
diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt
index 709674e6b43..87743911add 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -59,7 +59,6 @@ set(SRC
intern/MOD_gpencilthick.c
intern/MOD_gpenciltime.c
intern/MOD_gpenciltint.c
- intern/MOD_gpencilvertexcolor.c
MOD_gpencil_modifiertypes.h
)
diff --git a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
index b8e8e8fc87f..f5c064c1c07 100644
--- a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
+++ b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
@@ -43,7 +43,6 @@ extern GpencilModifierTypeInfo modifierType_Gpencil_Offset;
extern GpencilModifierTypeInfo modifierType_Gpencil_Armature;
extern GpencilModifierTypeInfo modifierType_Gpencil_Time;
extern GpencilModifierTypeInfo modifierType_Gpencil_Multiply;
-extern GpencilModifierTypeInfo modifierType_Gpencil_Vertexcolor;
/* MOD_gpencil_util.c */
void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[]);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index 1462b6f72c9..6c3815d7c0e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -72,7 +72,6 @@ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[])
INIT_GP_TYPE(Armature);
INIT_GP_TYPE(Time);
INIT_GP_TYPE(Multiply);
- INIT_GP_TYPE(Vertexcolor);
#undef INIT_GP_TYPE
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
index 96f1f004812..2b5a5192b4e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
@@ -25,34 +25,64 @@
#include "BLI_utildefines.h"
-#include "BLI_blenlib.h"
-#include "BLI_math_vector.h"
+#include "BLI_math.h"
+#include "BLI_listbase.h"
+#include "DNA_meshdata_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_gpencil_modifier_types.h"
+#include "DNA_modifier_types.h"
+#include "BKE_action.h"
+#include "BKE_colorband.h"
#include "BKE_colortools.h"
+#include "BKE_deform.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_modifier.h"
-#include "BKE_material.h"
+#include "BKE_layer.h"
+#include "BKE_lib_query.h"
#include "BKE_main.h"
+#include "BKE_material.h"
+#include "BKE_modifier.h"
+#include "BKE_scene.h"
-#include "DEG_depsgraph.h"
+#include "MEM_guardedalloc.h"
#include "MOD_gpencil_util.h"
#include "MOD_gpencil_modifiertypes.h"
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
+
static void initData(GpencilModifierData *md)
{
TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
gpmd->pass_index = 0;
- gpmd->factor = 0.5f;
gpmd->layername[0] = '\0';
gpmd->materialname[0] = '\0';
+ gpmd->vgname[0] = '\0';
+ gpmd->object = NULL;
+ gpmd->radius = 1.0f;
+ gpmd->factor = 0.5f;
ARRAY_SET_ITEMS(gpmd->rgb, 1.0f, 1.0f, 1.0f);
- gpmd->modify_color = GP_MODIFY_COLOR_BOTH;
+ gpmd->mode = GPPAINT_MODE_BOTH;
+
+ /* Add default color ramp. */
+ gpmd->colorband = BKE_colorband_add(false);
+ if (gpmd->colorband) {
+ BKE_colorband_init(gpmd->colorband, true);
+ CBData *ramp = gpmd->colorband->data;
+ ramp[0].r = ramp[0].g = ramp[0].b = ramp[0].a = 1.0f;
+ ramp[0].pos = 0.0f;
+ ramp[1].r = ramp[1].g = ramp[1].b = 0.0f;
+ ramp[1].a = 1.0f;
+ ramp[1].pos = 1.0f;
+
+ gpmd->colorband->tot = 2;
+ }
gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (gpmd->curve_intensity) {
@@ -66,6 +96,8 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
TintGpencilModifierData *gmd = (TintGpencilModifierData *)md;
TintGpencilModifierData *tgmd = (TintGpencilModifierData *)target;
+ MEM_SAFE_FREE(tgmd->colorband);
+
if (tgmd->curve_intensity != NULL) {
BKE_curvemapping_free(tgmd->curve_intensity);
tgmd->curve_intensity = NULL;
@@ -73,10 +105,14 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
BKE_gpencil_modifier_copyData_generic(md, target);
+ if (gmd->colorband) {
+ tgmd->colorband = MEM_dupallocN(gmd->colorband);
+ }
+
tgmd->curve_intensity = BKE_curvemapping_copy(gmd->curve_intensity);
}
-/* tint strokes */
+/* deform stroke */
static void deformStroke(GpencilModifierData *md,
Depsgraph *UNUSED(depsgraph),
Object *ob,
@@ -85,6 +121,11 @@ static void deformStroke(GpencilModifierData *md,
bGPDstroke *gps)
{
TintGpencilModifierData *mmd = (TintGpencilModifierData *)md;
+ if ((mmd->type == GP_TINT_GRADIENT) && (!mmd->object)) {
+ return;
+ }
+
+ const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname);
const bool use_curve = (mmd->flag & GP_TINT_CUSTOM_CURVE) != 0 && mmd->curve_intensity;
if (!is_stroke_affected_by_modifier(ob,
@@ -101,10 +142,10 @@ static void deformStroke(GpencilModifierData *md,
mmd->flag & GP_TINT_INVERT_MATERIAL)) {
return;
}
-
MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
+ const bool is_gradient = (mmd->type == GP_TINT_GRADIENT) != 0;
- /* if factor > 1.0, affect the strength of the stroke */
+ /* If factor > 1.0, affect the strength of the stroke. */
if (mmd->factor > 1.0f) {
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
@@ -113,67 +154,173 @@ static void deformStroke(GpencilModifierData *md,
}
}
- /* Apply to Vertex Color. */
- float mixfac = mmd->factor;
-
- CLAMP(mixfac, 0.0, 1.0f);
- /* Fill */
- if (mmd->modify_color != GP_MODIFY_COLOR_STROKE) {
- /* If not using Vertex Color, use the material color. */
- if ((gp_style != NULL) && (gps->vert_color_fill[3] == 0.0f) &&
- (gp_style->fill_rgba[3] > 0.0f)) {
- copy_v4_v4(gps->vert_color_fill, gp_style->fill_rgba);
- gps->vert_color_fill[3] = 1.0f;
+ float coba_res[4];
+ float matrix[4][4];
+ if (is_gradient) {
+ mul_m4_m4m4(matrix, mmd->object->imat, ob->obmat);
+ }
+
+ /* loop points and apply color. */
+ bool fill_done = false;
+ for (int i = 0; i < gps->totpoints; i++) {
+ bGPDspoint *pt = &gps->points[i];
+ MDeformVert *dvert = gps->dvert != NULL ? &gps->dvert[i] : NULL;
+
+ if (!fill_done) {
+ /* Apply to fill. */
+ if (mmd->mode != GPPAINT_MODE_STROKE) {
+
+ /* If not using Vertex Color, use the material color. */
+ if ((gp_style != NULL) && (gps->vert_color_fill[3] == 0.0f) &&
+ (gp_style->fill_rgba[3] > 0.0f)) {
+ copy_v4_v4(gps->vert_color_fill, gp_style->fill_rgba);
+ gps->vert_color_fill[3] = 1.0f;
+ }
+
+ if (is_gradient) {
+ float center[3];
+ add_v3_v3v3(center, gps->boundbox_min, gps->boundbox_max);
+ mul_v3_fl(center, 0.5f);
+ float pt_loc[3];
+ mul_v3_m4v3(pt_loc, matrix, &pt->x);
+ float dist = len_v3(pt_loc);
+ float mix_factor = clamp_f(dist / mmd->radius, 0.0f, 1.0f);
+
+ BKE_colorband_evaluate(mmd->colorband, mix_factor, coba_res);
+ interp_v3_v3v3(gps->vert_color_fill, gps->vert_color_fill, coba_res, mmd->factor);
+ gps->vert_color_fill[3] = clamp_f(mmd->factor, 0.0f, 1.0f);
+ }
+ else {
+ interp_v3_v3v3(gps->vert_color_fill,
+ gps->vert_color_fill,
+ mmd->rgb,
+ clamp_f(mmd->factor, 0.0f, 1.0f));
+ }
+ /* If no stroke, cancel loop. */
+ if (mmd->mode != GPPAINT_MODE_BOTH) {
+ break;
+ }
+ }
+
+ fill_done = true;
}
- interp_v3_v3v3(gps->vert_color_fill, gps->vert_color_fill, mmd->rgb, mixfac);
- }
+ /* Verify vertex group. */
+ if (mmd->mode != GPPAINT_MODE_FILL) {
+ float weight = get_modifier_point_weight(
+ dvert, (mmd->flag & GP_TINT_INVERT_VGROUP) != 0, def_nr);
+ if (weight < 0.0f) {
+ continue;
+ }
+ /* Custom curve to modulate value. */
+ if (use_curve) {
+ float value = (float)i / (gps->totpoints - 1);
+ weight *= BKE_curvemapping_evaluateF(mmd->curve_intensity, 0, value);
+ }
- /* Stroke */
- if (mmd->modify_color != GP_MODIFY_COLOR_FILL) {
- for (int i = 0; i < gps->totpoints; i++) {
- bGPDspoint *pt = &gps->points[i];
/* If not using Vertex Color, use the material color. */
if ((gp_style != NULL) && (pt->vert_color[3] == 0.0f) && (gp_style->stroke_rgba[3] > 0.0f)) {
copy_v4_v4(pt->vert_color, gp_style->stroke_rgba);
pt->vert_color[3] = 1.0f;
}
- /* Custom curve to modulate value. */
- float mixvalue = mixfac;
- if (use_curve) {
- float value = (float)i / (gps->totpoints - 1);
- mixvalue *= BKE_curvemapping_evaluateF(mmd->curve_intensity, 0, value);
- }
+ if (is_gradient) {
+ /* Calc world position of point. */
+ float pt_loc[3];
+ mul_v3_m4v3(pt_loc, matrix, &pt->x);
+ float dist = len_v3(pt_loc);
+
+ /* Calc the factor using the distance and get mix color. */
+ float mix_factor = clamp_f(dist / mmd->radius, 0.0f, 1.0f);
+ BKE_colorband_evaluate(mmd->colorband, mix_factor, coba_res);
- interp_v3_v3v3(pt->vert_color, pt->vert_color, mmd->rgb, mixvalue);
+ interp_v3_v3v3(pt->vert_color,
+ pt->vert_color,
+ coba_res,
+ clamp_f(mmd->factor, 0.0f, 1.0f) * weight * coba_res[3]);
+ }
+ else {
+ interp_v3_v3v3(
+ pt->vert_color, pt->vert_color, mmd->rgb, clamp_f(mmd->factor * weight, 0.0, 1.0f));
+ }
}
}
}
-static void bakeModifier(Main *UNUSED(bmain),
- Depsgraph *depsgraph,
- GpencilModifierData *md,
- Object *ob)
+/* FIXME: Ideally we be doing this on a copy of the main depsgraph
+ * (i.e. one where we don't have to worry about restoring state)
+ */
+static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData *md, Object *ob)
{
+ TintGpencilModifierData *mmd = (TintGpencilModifierData *)md;
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
bGPdata *gpd = ob->data;
+ int oldframe = (int)DEG_get_ctime(depsgraph);
+
+ if (mmd->object == NULL) {
+ return;
+ }
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
+ /* apply effects on this frame
+ * NOTE: this assumes that we don't want animation on non-keyframed frames
+ */
+ CFRA = gpf->framenum;
+ BKE_scene_graph_update_for_newframe(depsgraph, bmain);
+
+ /* compute effects on this frame */
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
deformStroke(md, depsgraph, ob, gpl, gpf, gps);
}
}
}
+
+ /* return frame state and DB to original state */
+ CFRA = oldframe;
+ BKE_scene_graph_update_for_newframe(depsgraph, bmain);
}
static void freeData(GpencilModifierData *md)
{
- TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
+ TintGpencilModifierData *mmd = (TintGpencilModifierData *)md;
+ if (mmd->colorband) {
+ MEM_freeN(mmd->colorband);
+ mmd->colorband = NULL;
+ }
+ if (mmd->curve_intensity) {
+ BKE_curvemapping_free(mmd->curve_intensity);
+ }
+}
- if (gpmd->curve_intensity) {
- BKE_curvemapping_free(gpmd->curve_intensity);
+static bool isDisabled(GpencilModifierData *md, int UNUSED(userRenderParams))
+{
+ TintGpencilModifierData *mmd = (TintGpencilModifierData *)md;
+ if (mmd->type == GP_TINT_UNIFORM) {
+ return false;
+ }
+
+ return !mmd->object;
+}
+
+static void updateDepsgraph(GpencilModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
+{
+ TintGpencilModifierData *lmd = (TintGpencilModifierData *)md;
+ if (lmd->object != NULL) {
+ DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_GEOMETRY, "Vertexcolor Modifier");
+ DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_TRANSFORM, "Vertexcolor Modifier");
}
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Vertexcolor Modifier");
+}
+
+static void foreachObjectLink(GpencilModifierData *md,
+ Object *ob,
+ ObjectWalkFunc walk,
+ void *userData)
+{
+ TintGpencilModifierData *mmd = (TintGpencilModifierData *)md;
+
+ walk(userData, ob, &mmd->object, IDWALK_CB_NOP);
}
GpencilModifierTypeInfo modifierType_Gpencil_Tint = {
@@ -192,10 +339,10 @@ GpencilModifierTypeInfo modifierType_Gpencil_Tint = {
/* initData */ initData,
/* freeData */ freeData,
- /* isDisabled */ NULL,
- /* updateDepsgraph */ NULL,
+ /* isDisabled */ isDisabled,
+ /* updateDepsgraph */ updateDepsgraph,
/* dependsOnTime */ NULL,
- /* foreachObjectLink */ NULL,
+ /* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
};
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c
deleted file mode 100644
index b279d90dd4f..00000000000
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2017, Blender Foundation
- * This is a new part of Blender
- */
-
-/** \file
- * \ingroup modifiers
- */
-
-#include <stdio.h>
-
-#include "BLI_utildefines.h"
-
-#include "BLI_math.h"
-#include "BLI_listbase.h"
-
-#include "DNA_meshdata_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h"
-#include "DNA_gpencil_types.h"
-#include "DNA_gpencil_modifier_types.h"
-#include "DNA_modifier_types.h"
-
-#include "BKE_action.h"
-#include "BKE_colorband.h"
-#include "BKE_colortools.h"
-#include "BKE_deform.h"
-#include "BKE_gpencil.h"
-#include "BKE_gpencil_modifier.h"
-#include "BKE_layer.h"
-#include "BKE_lib_query.h"
-#include "BKE_main.h"
-#include "BKE_material.h"
-#include "BKE_modifier.h"
-#include "BKE_scene.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "MOD_gpencil_util.h"
-#include "MOD_gpencil_modifiertypes.h"
-
-#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_build.h"
-#include "DEG_depsgraph_query.h"
-
-static void initData(GpencilModifierData *md)
-{
- VertexcolorGpencilModifierData *gpmd = (VertexcolorGpencilModifierData *)md;
- gpmd->pass_index = 0;
- gpmd->layername[0] = '\0';
- gpmd->materialname[0] = '\0';
- gpmd->vgname[0] = '\0';
- gpmd->object = NULL;
- gpmd->radius = 1.0f;
- gpmd->factor = 1.0f;
-
- /* Add default color ramp. */
- gpmd->colorband = BKE_colorband_add(false);
- if (gpmd->colorband) {
- BKE_colorband_init(gpmd->colorband, true);
- CBData *ramp = gpmd->colorband->data;
- ramp[0].r = ramp[0].g = ramp[0].b = ramp[0].a = 1.0f;
- ramp[0].pos = 0.0f;
- ramp[1].r = ramp[1].g = ramp[1].b = 0.0f;
- ramp[1].a = 1.0f;
- ramp[1].pos = 1.0f;
-
- gpmd->colorband->tot = 2;
- }
-
- gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- if (gpmd->curve_intensity) {
- CurveMapping *curve = gpmd->curve_intensity;
- BKE_curvemapping_initialize(curve);
- }
-}
-
-static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
-{
- VertexcolorGpencilModifierData *gmd = (VertexcolorGpencilModifierData *)md;
- VertexcolorGpencilModifierData *tgmd = (VertexcolorGpencilModifierData *)target;
-
- MEM_SAFE_FREE(tgmd->colorband);
-
- if (tgmd->curve_intensity != NULL) {
- BKE_curvemapping_free(tgmd->curve_intensity);
- tgmd->curve_intensity = NULL;
- }
-
- BKE_gpencil_modifier_copyData_generic(md, target);
-
- if (gmd->colorband) {
- tgmd->colorband = MEM_dupallocN(gmd->colorband);
- }
-
- tgmd->curve_intensity = BKE_curvemapping_copy(gmd->curve_intensity);
-}
-
-/* deform stroke */
-static void deformStroke(GpencilModifierData *md,
- Depsgraph *UNUSED(depsgraph),
- Object *ob,
- bGPDlayer *gpl,
- bGPDframe *UNUSED(gpf),
- bGPDstroke *gps)
-{
- VertexcolorGpencilModifierData *mmd = (VertexcolorGpencilModifierData *)md;
- if (!mmd->object) {
- return;
- }
-
- const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname);
- const bool use_curve = (mmd->flag & GP_VERTEXCOL_CUSTOM_CURVE) != 0 && mmd->curve_intensity;
-
- if (!is_stroke_affected_by_modifier(ob,
- mmd->layername,
- mmd->materialname,
- mmd->pass_index,
- mmd->layer_pass,
- 1,
- gpl,
- gps,
- mmd->flag & GP_VERTEXCOL_INVERT_LAYER,
- mmd->flag & GP_VERTEXCOL_INVERT_PASS,
- mmd->flag & GP_VERTEXCOL_INVERT_LAYERPASS,
- mmd->flag & GP_VERTEXCOL_INVERT_MATERIAL)) {
- return;
- }
- MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
-
- float coba_res[4];
- float matrix[4][4];
- mul_m4_m4m4(matrix, mmd->object->imat, ob->obmat);
-
- /* loop points and apply deform */
- bool fill_done = false;
- for (int i = 0; i < gps->totpoints; i++) {
- bGPDspoint *pt = &gps->points[i];
- MDeformVert *dvert = gps->dvert != NULL ? &gps->dvert[i] : NULL;
-
- if (!fill_done) {
- /* Apply to fill. */
- if (mmd->mode != GPPAINT_MODE_STROKE) {
-
- /* If not using Vertex Color, use the material color. */
- if ((gp_style != NULL) && (gps->vert_color_fill[3] == 0.0f) &&
- (gp_style->fill_rgba[3] > 0.0f)) {
- copy_v4_v4(gps->vert_color_fill, gp_style->fill_rgba);
- gps->vert_color_fill[3] = 1.0f;
- }
-
- float center[3];
- add_v3_v3v3(center, gps->boundbox_min, gps->boundbox_max);
- mul_v3_fl(center, 0.5f);
- float pt_loc[3];
- mul_v3_m4v3(pt_loc, matrix, &pt->x);
- float dist = len_v3(pt_loc);
- float mix_factor = clamp_f(dist / mmd->radius, 0.0f, 1.0f);
-
- BKE_colorband_evaluate(mmd->colorband, mix_factor, coba_res);
- interp_v3_v3v3(gps->vert_color_fill, gps->vert_color_fill, coba_res, mmd->factor);
- gps->vert_color_fill[3] = mmd->factor;
- /* If no stroke, cancel loop. */
- if (mmd->mode != GPPAINT_MODE_BOTH) {
- break;
- }
- }
-
- fill_done = true;
- }
-
- /* Verify vertex group. */
- if (mmd->mode != GPPAINT_MODE_FILL) {
- float weight = get_modifier_point_weight(
- dvert, (mmd->flag & GP_VERTEXCOL_INVERT_VGROUP) != 0, def_nr);
- if (weight < 0.0f) {
- continue;
- }
- /* Custom curve to modulate value. */
- if (use_curve) {
- float value = (float)i / (gps->totpoints - 1);
- weight *= BKE_curvemapping_evaluateF(mmd->curve_intensity, 0, value);
- }
-
- /* Calc world position of point. */
- float pt_loc[3];
- mul_v3_m4v3(pt_loc, matrix, &pt->x);
- float dist = len_v3(pt_loc);
-
- /* If not using Vertex Color, use the material color. */
- if ((gp_style != NULL) && (pt->vert_color[3] == 0.0f) && (gp_style->stroke_rgba[3] > 0.0f)) {
- copy_v4_v4(pt->vert_color, gp_style->stroke_rgba);
- pt->vert_color[3] = 1.0f;
- }
-
- /* Calc the factor using the distance and get mix color. */
- float mix_factor = clamp_f(dist / mmd->radius, 0.0f, 1.0f);
- BKE_colorband_evaluate(mmd->colorband, mix_factor, coba_res);
-
- interp_v3_v3v3(pt->vert_color, pt->vert_color, coba_res, mmd->factor * weight * coba_res[3]);
- }
- }
-}
-
-/* FIXME: Ideally we be doing this on a copy of the main depsgraph
- * (i.e. one where we don't have to worry about restoring state)
- */
-static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData *md, Object *ob)
-{
- VertexcolorGpencilModifierData *mmd = (VertexcolorGpencilModifierData *)md;
- Scene *scene = DEG_get_evaluated_scene(depsgraph);
- bGPdata *gpd = ob->data;
- int oldframe = (int)DEG_get_ctime(depsgraph);
-
- if (mmd->object == NULL) {
- return;
- }
-
- LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
- LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
- /* apply effects on this frame
- * NOTE: this assumes that we don't want animation on non-keyframed frames
- */
- CFRA = gpf->framenum;
- BKE_scene_graph_update_for_newframe(depsgraph, bmain);
-
- /* compute effects on this frame */
- LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- deformStroke(md, depsgraph, ob, gpl, gpf, gps);
- }
- }
- }
-
- /* return frame state and DB to original state */
- CFRA = oldframe;
- BKE_scene_graph_update_for_newframe(depsgraph, bmain);
-}
-
-static void freeData(GpencilModifierData *md)
-{
- VertexcolorGpencilModifierData *mmd = (VertexcolorGpencilModifierData *)md;
- if (mmd->colorband) {
- MEM_freeN(mmd->colorband);
- mmd->colorband = NULL;
- }
- if (mmd->curve_intensity) {
- BKE_curvemapping_free(mmd->curve_intensity);
- }
-}
-
-static bool isDisabled(GpencilModifierData *md, int UNUSED(userRenderParams))
-{
- VertexcolorGpencilModifierData *mmd = (VertexcolorGpencilModifierData *)md;
-
- return !mmd->object;
-}
-
-static void updateDepsgraph(GpencilModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
-{
- VertexcolorGpencilModifierData *lmd = (VertexcolorGpencilModifierData *)md;
- if (lmd->object != NULL) {
- DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_GEOMETRY, "Vertexcolor Modifier");
- DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_TRANSFORM, "Vertexcolor Modifier");
- }
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Vertexcolor Modifier");
-}
-
-static void foreachObjectLink(GpencilModifierData *md,
- Object *ob,
- ObjectWalkFunc walk,
- void *userData)
-{
- VertexcolorGpencilModifierData *mmd = (VertexcolorGpencilModifierData *)md;
-
- walk(userData, ob, &mmd->object, IDWALK_CB_NOP);
-}
-
-GpencilModifierTypeInfo modifierType_Gpencil_Vertexcolor = {
- /* name */ "Vertex Color",
- /* structName */ "VertexcolorGpencilModifierData",
- /* structSize */ sizeof(VertexcolorGpencilModifierData),
- /* type */ eGpencilModifierTypeType_Gpencil,
- /* flags */ eGpencilModifierTypeFlag_SupportsEditmode,
-
- /* copyData */ copyData,
-
- /* deformStroke */ deformStroke,
- /* generateStrokes */ NULL,
- /* bakeModifier */ bakeModifier,
- /* remapTime */ NULL,
-
- /* initData */ initData,
- /* freeData */ freeData,
- /* isDisabled */ isDisabled,
- /* updateDepsgraph */ updateDepsgraph,
- /* dependsOnTime */ NULL,
- /* foreachObjectLink */ foreachObjectLink,
- /* foreachIDLink */ NULL,
- /* foreachTexLink */ NULL,
-};
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index 1121bdf4df0..4f1dd08cd30 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -47,7 +47,6 @@ typedef enum GpencilModifierType {
eGpencilModifierType_Armature = 15,
eGpencilModifierType_Time = 16,
eGpencilModifierType_Multiply = 17,
- eGpencilModifierType_Vertexcolor = 18,
NUM_GREASEPENCIL_MODIFIER_TYPES,
} GpencilModifierType;
@@ -223,38 +222,6 @@ typedef enum eOpacityModesGpencil_Flag {
GP_OPACITY_MODE_STRENGTH = 1,
} eOpacityModesGpencil_Flag;
-typedef struct TintGpencilModifierData {
- GpencilModifierData modifier;
- /** Layer name. */
- char layername[64];
- /** Material name. */
- char materialname[64];
- /** Custom index for passes. */
- int pass_index;
- /** Flags. */
- int flag;
- /** Tint color. */
- float rgb[3];
- /** Mix factor. */
- float factor;
- /** Modify stroke, fill or both. */
- char modify_color;
- char _pad[7];
- /** Custom index for passes. */
- int layer_pass;
-
- char _pad1[4];
- struct CurveMapping *curve_intensity;
-} TintGpencilModifierData;
-
-typedef enum eTintGpencil_Flag {
- GP_TINT_INVERT_LAYER = (1 << 1),
- GP_TINT_INVERT_PASS = (1 << 2),
- GP_TINT_INVERT_LAYERPASS = (1 << 3),
- GP_TINT_INVERT_MATERIAL = (1 << 4),
- GP_TINT_CUSTOM_CURVE = (1 << 5),
-} eTintGpencil_Flag;
-
typedef struct ColorGpencilModifierData {
GpencilModifierData modifier;
/** Layer name. */
@@ -700,7 +667,7 @@ typedef enum eMultiplyGpencil_Flag {
GP_MULTIPLY_ENABLE_FADING = (1 << 2),
} eMultiplyGpencil_Flag;
-typedef struct VertexcolorGpencilModifierData {
+typedef struct TintGpencilModifierData {
GpencilModifierData modifier;
struct Object *object;
@@ -716,25 +683,33 @@ typedef struct VertexcolorGpencilModifierData {
int layer_pass;
/** Flags. */
int flag;
- /** Mode. */
+ /** Mode (Stroke/Fill/Both). */
int mode;
float factor;
float radius;
+ /** Simple Tint color. */
+ float rgb[3];
+ /** Type of Tint. */
+ int type;
struct CurveMapping *curve_intensity;
struct ColorBand *colorband;
-} VertexcolorGpencilModifierData;
-
-typedef enum eVertexcolorGpencil_Flag {
- GP_VERTEXCOL_INVERT_LAYER = (1 << 0),
- GP_VERTEXCOL_INVERT_PASS = (1 << 1),
- GP_VERTEXCOL_INVERT_VGROUP = (1 << 2),
- GP_VERTEXCOL_UNIFORM_SPACE = (1 << 3),
- GP_VERTEXCOL_INVERT_LAYERPASS = (1 << 4),
- GP_VERTEXCOL_INVERT_MATERIAL = (1 << 5),
- GP_VERTEXCOL_CUSTOM_CURVE = (1 << 6),
-} eVertexcolorGpencil_Flag;
+} TintGpencilModifierData;
+
+typedef enum eTintGpencil_Type {
+ GP_TINT_UNIFORM = 0,
+ GP_TINT_GRADIENT = 1,
+} eTintGpencil_Type;
+
+typedef enum eTintGpencil_Flag {
+ GP_TINT_INVERT_LAYER = (1 << 0),
+ GP_TINT_INVERT_PASS = (1 << 1),
+ GP_TINT_INVERT_VGROUP = (1 << 2),
+ GP_TINT_INVERT_LAYERPASS = (1 << 4),
+ GP_TINT_INVERT_MATERIAL = (1 << 5),
+ GP_TINT_CUSTOM_CURVE = (1 << 6),
+} eTintGpencil_Flag;
#endif /* __DNA_GPENCIL_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 0caa93940c8..96c4fe3740e 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -129,11 +129,6 @@ const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = {
"Opacity",
"Opacity of the strokes"},
{eGpencilModifierType_Tint, "GP_TINT", ICON_MOD_TINT, "Tint", "Tint strokes with new color"},
- {eGpencilModifierType_Vertexcolor,
- "GP_VERTEXCOLOR",
- ICON_MOD_NORMALEDIT,
- "Vertex Color",
- "Apply color changes to Vertex Color"},
{0, NULL, 0, NULL, NULL},
};
@@ -170,6 +165,11 @@ static const EnumPropertyItem gpencil_subdivision_type_items[] = {
{GP_SUBDIV_SIMPLE, "SIMPLE", 0, "Simple", ""},
{0, NULL, 0, NULL, NULL},
};
+static const EnumPropertyItem gpencil_tint_type_items[] = {
+ {GP_TINT_UNIFORM, "UNIFORM", 0, "Uniform", ""},
+ {GP_TINT_GRADIENT, "GRADIENT", 0, "Gradient", ""},
+ {0, NULL, 0, NULL, NULL},
+};
#endif
#ifdef RNA_RUNTIME
@@ -226,8 +226,6 @@ static StructRNA *rna_GpencilModifier_refine(struct PointerRNA *ptr)
return &RNA_ArmatureGpencilModifier;
case eGpencilModifierType_Multiply:
return &RNA_MultiplyGpencilModifier;
- case eGpencilModifierType_Vertexcolor:
- return &RNA_VertexcolorGpencilModifier;
/* Default */
case eGpencilModifierType_None:
case NUM_GREASEPENCIL_MODIFIER_TYPES:
@@ -342,11 +340,11 @@ static void rna_HookGpencilModifier_object_set(PointerRNA *ptr,
BKE_object_modifier_gpencil_hook_reset(ob, hmd);
}
-static void rna_VertexcolorGpencilModifier_object_set(PointerRNA *ptr,
- PointerRNA value,
- struct ReportList *UNUSED(reports))
+static void rna_TintGpencilModifier_object_set(PointerRNA *ptr,
+ PointerRNA value,
+ struct ReportList *UNUSED(reports))
{
- VertexcolorGpencilModifierData *hmd = ptr->data;
+ TintGpencilModifierData *hmd = ptr->data;
Object *ob = (Object *)value.data;
hmd->object = ob;
@@ -1018,15 +1016,25 @@ static void rna_def_modifier_gpenciltint(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ /* modes */
+ static EnumPropertyItem tint_mode_types_items[] = {
+ {GPPAINT_MODE_STROKE, "STROKE", 0, "Stroke", "Vertex Color affects to Stroke only"},
+ {GPPAINT_MODE_FILL, "FILL", 0, "Fill", "Vertex Color affects to Fill only"},
+ {GPPAINT_MODE_BOTH, "BOTH", 0, "Both", "Vertex Color affects to Stroke and Fill"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
srna = RNA_def_struct(brna, "TintGpencilModifier", "GpencilModifier");
- RNA_def_struct_ui_text(srna, "Tint Modifier", "Tint Stroke Color modifier");
+ RNA_def_struct_ui_text(srna, "Tint Modifier", "Tint modifier");
RNA_def_struct_sdna(srna, "TintGpencilModifierData");
RNA_def_struct_ui_icon(srna, ICON_COLOR);
- prop = RNA_def_property(srna, "modify_color", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, modifier_modify_color_items); /* share the enum */
- RNA_def_property_ui_text(prop, "Mode", "Set what colors of the stroke are affected");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+ prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Object", "Parent object to define the center of the effect");
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+ RNA_def_property_pointer_funcs(prop, NULL, "rna_TintGpencilModifier_object_set", NULL, NULL);
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "layername");
@@ -1038,17 +1046,10 @@ static void rna_def_modifier_gpenciltint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Material", "Material name");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_range(prop, 0.0, 1.0);
- RNA_def_property_float_sdna(prop, NULL, "rgb");
- RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Color", "Color used for tinting");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "factor");
- RNA_def_property_ui_range(prop, 0, 2.0, 0.1, 2);
- RNA_def_property_ui_text(prop, "Factor", "Factor for mixing color");
+ prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "vgname");
+ RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_HookGpencilModifier_vgname_set");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE);
@@ -1072,6 +1073,11 @@ static void rna_def_modifier_gpenciltint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+ prop = RNA_def_property(srna, "invert_vertex", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TINT_INVERT_VGROUP);
+ RNA_def_property_ui_text(prop, "Inverse Vertex Group", "Inverse filter");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "layer_pass");
RNA_def_property_range(prop, 0, 100);
@@ -1083,10 +1089,54 @@ static void rna_def_modifier_gpenciltint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+ prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "factor");
+ RNA_def_property_range(prop, 0, 2.0);
+ RNA_def_property_ui_range(prop, 0, 2.0, 0.1, 2);
+ RNA_def_property_ui_text(prop, "Strength", "Factor for tinting");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_sdna(prop, NULL, "radius");
+ RNA_def_property_range(prop, 1e-6f, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 1, 3);
+ RNA_def_property_ui_text(prop, "Radius", "Defines the maximum distance of the effect");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ /* Mode type. */
+ prop = RNA_def_property(srna, "vertex_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
+ RNA_def_property_enum_items(prop, tint_mode_types_items);
+ RNA_def_property_ui_text(prop, "Mode", "Defines how vertex color affect to the strokes");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ /* Type of Tint. */
+ prop = RNA_def_property(srna, "tint_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type");
+ RNA_def_property_enum_items(prop, gpencil_tint_type_items);
+ RNA_def_property_ui_text(prop, "Tint Type", "Select type of tinting algorithm");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ /* Simple Color. */
+ prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_range(prop, 0.0, 1.0);
+ RNA_def_property_float_sdna(prop, NULL, "rgb");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Color", "Color used for tinting");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ /* Color band. */
+ prop = RNA_def_property(srna, "colors", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "colorband");
+ RNA_def_property_struct_type(prop, "ColorRamp");
+ RNA_def_property_ui_text(prop, "Colors", "Color ramp used to define tinting colors");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
prop = RNA_def_property(srna, "use_custom_curve", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TINT_CUSTOM_CURVE);
RNA_def_property_ui_text(
- prop, "Custom Curve", "Use a custom curve to define tint effect along the strokes");
+ prop, "Custom Curve", "Use a custom curve to define vertex color effect along the strokes");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
@@ -2078,125 +2128,6 @@ static void rna_def_modifier_gpencilmultiply(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
}
-static void rna_def_modifier_gpencilvertexcolor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- /* modes */
- static EnumPropertyItem vertexcol_mode_types_items[] = {
- {GPPAINT_MODE_STROKE, "STROKE", 0, "Stroke", "Vertex Color affects to Stroke only"},
- {GPPAINT_MODE_FILL, "FILL", 0, "Fill", "Vertex Color affects to Fill only"},
- {GPPAINT_MODE_BOTH, "BOTH", 0, "Both", "Vertex Color affects to Stroke and Fill"},
- {0, NULL, 0, NULL, NULL},
- };
-
- srna = RNA_def_struct(brna, "VertexcolorGpencilModifier", "GpencilModifier");
- RNA_def_struct_ui_text(srna, "Vertexcolor Modifier", "Vertex color modifier");
- RNA_def_struct_sdna(srna, "VertexcolorGpencilModifierData");
- RNA_def_struct_ui_icon(srna, ICON_MOD_NORMALEDIT);
-
- prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
- RNA_def_property_ui_text(prop, "Object", "Parent object to define the center of the effect");
- RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
- RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
- RNA_def_property_pointer_funcs(
- prop, NULL, "rna_VertexcolorGpencilModifier_object_set", NULL, NULL);
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
-
- prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "layername");
- RNA_def_property_ui_text(prop, "Layer", "Layer name");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "materialname");
- RNA_def_property_ui_text(prop, "Material", "Material name");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "vgname");
- RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform");
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_HookGpencilModifier_vgname_set");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "pass_index");
- RNA_def_property_range(prop, 0, 100);
- RNA_def_property_ui_text(prop, "Pass", "Pass index");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_VERTEXCOL_INVERT_LAYER);
- RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "invert_materials", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_VERTEXCOL_INVERT_MATERIAL);
- RNA_def_property_ui_text(prop, "Inverse Materials", "Inverse filter");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_VERTEXCOL_INVERT_PASS);
- RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "invert_vertex", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_VERTEXCOL_INVERT_VGROUP);
- RNA_def_property_ui_text(prop, "Inverse Vertex Group", "Inverse filter");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "layer_pass");
- RNA_def_property_range(prop, 0, 100);
- RNA_def_property_ui_text(prop, "Pass", "Layer pass index");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_VERTEXCOL_INVERT_LAYERPASS);
- RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "factor");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Factor", "Factor of tinting");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_DISTANCE);
- RNA_def_property_float_sdna(prop, NULL, "radius");
- RNA_def_property_range(prop, 1e-6f, FLT_MAX);
- RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 1, 3);
- RNA_def_property_ui_text(prop, "Radius", "Defines the maximum distance of the effect");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- /* Mode type. */
- prop = RNA_def_property(srna, "vertex_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, vertexcol_mode_types_items);
- RNA_def_property_ui_text(prop, "Mode", "Defines how vertex color affect to the strokes");
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- /* Color band */
- prop = RNA_def_property(srna, "colors", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "colorband");
- RNA_def_property_struct_type(prop, "ColorRamp");
- RNA_def_property_ui_text(prop, "Colors", "Color ramp used to define tinting colors");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "use_custom_curve", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_VERTEXCOL_CUSTOM_CURVE);
- RNA_def_property_ui_text(
- prop, "Custom Curve", "Use a custom curve to define vertex color effect along the strokes");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
- prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "curve_intensity");
- RNA_def_property_ui_text(prop, "Curve", "Custom curve to apply effect");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-}
-
void RNA_def_greasepencil_modifier(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2270,7 +2201,6 @@ void RNA_def_greasepencil_modifier(BlenderRNA *brna)
rna_def_modifier_gpencilhook(brna);
rna_def_modifier_gpencilarmature(brna);
rna_def_modifier_gpencilmultiply(brna);
- rna_def_modifier_gpencilvertexcolor(brna);
}
#endif