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-05-07 16:02:21 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-05-07 16:11:16 +0300
commitb571516237a94e944b9182d233b9ba64819d92c4 (patch)
tree89a3b9446acc83730cd81886d44b16f0fdadbe1e /source/blender
parent9b7754883b3d41d41cd2df3b079cc1fce78c044a (diff)
GPencil: Include new Brush random curves
Now the brushes have several new random settings and use curves to define the effect. The curves have been moved below the parameter to keep UI standards and extra curve panels have been removed. {F8505387} The new curves are: * Hue. * Saturation. * Value. New option to random at stroke level instead to random at point level for the following values: * Thickness. * Strength. * UV. * Hue. * Saturation. * Value. Curves have been moved below the corresponding parameter and only are displayed in properties panel. Display the curves in the popover made it unusable. {F8505392} Also, the Pressure random has been renamed to Radius because the old name was not clear enough. Reviewed By: mendio, pablovazquez Differential Revision: https://developer.blender.org/D7577
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/brush.c28
-rw-r--r--source/blender/blenloader/intern/readfile.c37
-rw-r--r--source/blender/blenloader/intern/versioning_280.c7
-rw-r--r--source/blender/blenloader/intern/versioning_290.c21
-rw-r--r--source/blender/blenloader/intern/writefile.c18
-rw-r--r--source/blender/draw/intern/draw_cache_impl_gpencil.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h15
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c169
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c129
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c171
-rw-r--r--source/blender/editors/include/ED_gpencil.h29
-rw-r--r--source/blender/makesdna/DNA_brush_types.h44
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_brush.c150
15 files changed, 700 insertions, 125 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index f0ea820a1ac..0e6b9409404 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -89,6 +89,19 @@ static void brush_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c
brush_src->gpencil_settings->curve_strength);
brush_dst->gpencil_settings->curve_jitter = BKE_curvemapping_copy(
brush_src->gpencil_settings->curve_jitter);
+
+ brush_dst->gpencil_settings->curve_rand_pressure = BKE_curvemapping_copy(
+ brush_src->gpencil_settings->curve_rand_pressure);
+ brush_dst->gpencil_settings->curve_rand_strength = BKE_curvemapping_copy(
+ brush_src->gpencil_settings->curve_rand_strength);
+ brush_dst->gpencil_settings->curve_rand_uv = BKE_curvemapping_copy(
+ brush_src->gpencil_settings->curve_rand_uv);
+ brush_dst->gpencil_settings->curve_rand_hue = BKE_curvemapping_copy(
+ brush_src->gpencil_settings->curve_rand_hue);
+ brush_dst->gpencil_settings->curve_rand_saturation = BKE_curvemapping_copy(
+ brush_src->gpencil_settings->curve_rand_saturation);
+ brush_dst->gpencil_settings->curve_rand_value = BKE_curvemapping_copy(
+ brush_src->gpencil_settings->curve_rand_value);
}
/* enable fake user by default */
@@ -107,6 +120,14 @@ static void brush_free_data(ID *id)
BKE_curvemapping_free(brush->gpencil_settings->curve_sensitivity);
BKE_curvemapping_free(brush->gpencil_settings->curve_strength);
BKE_curvemapping_free(brush->gpencil_settings->curve_jitter);
+
+ BKE_curvemapping_free(brush->gpencil_settings->curve_rand_pressure);
+ BKE_curvemapping_free(brush->gpencil_settings->curve_rand_strength);
+ BKE_curvemapping_free(brush->gpencil_settings->curve_rand_uv);
+ BKE_curvemapping_free(brush->gpencil_settings->curve_rand_hue);
+ BKE_curvemapping_free(brush->gpencil_settings->curve_rand_saturation);
+ BKE_curvemapping_free(brush->gpencil_settings->curve_rand_value);
+
MEM_SAFE_FREE(brush->gpencil_settings);
}
@@ -280,6 +301,13 @@ void BKE_brush_init_gpencil_settings(Brush *brush)
brush->gpencil_settings->curve_sensitivity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
brush->gpencil_settings->curve_strength = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
brush->gpencil_settings->curve_jitter = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+
+ brush->gpencil_settings->curve_rand_pressure = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ brush->gpencil_settings->curve_rand_strength = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ brush->gpencil_settings->curve_rand_uv = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ brush->gpencil_settings->curve_rand_hue = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ brush->gpencil_settings->curve_rand_saturation = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ brush->gpencil_settings->curve_rand_value = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
}
/* add a new gp-brush */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 418750a8df2..cf690b18931 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3001,6 +3001,19 @@ static void direct_link_brush(FileData *fd, Brush *brush)
brush->gpencil_settings->curve_strength);
brush->gpencil_settings->curve_jitter = newdataadr(fd, brush->gpencil_settings->curve_jitter);
+ brush->gpencil_settings->curve_rand_pressure = newdataadr(
+ fd, brush->gpencil_settings->curve_rand_pressure);
+ brush->gpencil_settings->curve_rand_strength = newdataadr(
+ fd, brush->gpencil_settings->curve_rand_strength);
+ brush->gpencil_settings->curve_rand_uv = newdataadr(fd,
+ brush->gpencil_settings->curve_rand_uv);
+ brush->gpencil_settings->curve_rand_hue = newdataadr(fd,
+ brush->gpencil_settings->curve_rand_hue);
+ brush->gpencil_settings->curve_rand_saturation = newdataadr(
+ fd, brush->gpencil_settings->curve_rand_saturation);
+ brush->gpencil_settings->curve_rand_value = newdataadr(
+ fd, brush->gpencil_settings->curve_rand_value);
+
if (brush->gpencil_settings->curve_sensitivity) {
direct_link_curvemapping(fd, brush->gpencil_settings->curve_sensitivity);
}
@@ -3012,6 +3025,30 @@ static void direct_link_brush(FileData *fd, Brush *brush)
if (brush->gpencil_settings->curve_jitter) {
direct_link_curvemapping(fd, brush->gpencil_settings->curve_jitter);
}
+
+ if (brush->gpencil_settings->curve_rand_pressure) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_pressure);
+ }
+
+ if (brush->gpencil_settings->curve_rand_strength) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_strength);
+ }
+
+ if (brush->gpencil_settings->curve_rand_uv) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_uv);
+ }
+
+ if (brush->gpencil_settings->curve_rand_hue) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_hue);
+ }
+
+ if (brush->gpencil_settings->curve_rand_saturation) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_saturation);
+ }
+
+ if (brush->gpencil_settings->curve_rand_value) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_value);
+ }
}
brush->preview = NULL;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 1879ab10fef..cc9a23dbf68 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -4648,6 +4648,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
brush->gpencil_weight_tool = brush->gpencil_settings->brush_type;
}
}
+ /* Tint brush. */
+ Brush *brush = BLI_findstring(&bmain->brushes, "Tint", offsetof(ID, name) + 2);
+ if (brush == NULL) {
+ brush = BKE_brush_add(bmain, "Tint", OB_MODE_PAINT_GPENCIL);
+ BKE_brush_init_gpencil_settings(brush);
+ }
+ BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_TINT);
BKE_paint_toolslots_init_from_main(bmain);
}
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 0ce3cf405cd..40f6689e43b 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -23,10 +23,12 @@
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
+#include "DNA_brush_types.h"
#include "DNA_genfile.h"
#include "DNA_screen_types.h"
#include "BKE_collection.h"
+#include "BKE_colortools.h"
#include "BKE_main.h"
#include "BLO_readfile.h"
@@ -62,5 +64,24 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ /* Init Grease Pencil new random curves. */
+ if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "float", "random_hue")) {
+ LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
+ if ((brush->gpencil_settings) && (brush->gpencil_settings->curve_rand_pressure == NULL)) {
+ brush->gpencil_settings->curve_rand_pressure = BKE_curvemapping_add(
+ 1, 0.0f, 0.0f, 1.0f, 1.0f);
+ brush->gpencil_settings->curve_rand_strength = BKE_curvemapping_add(
+ 1, 0.0f, 0.0f, 1.0f, 1.0f);
+ brush->gpencil_settings->curve_rand_uv = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ brush->gpencil_settings->curve_rand_hue = BKE_curvemapping_add(
+ 1, 0.0f, 0.0f, 1.0f, 1.0f);
+ brush->gpencil_settings->curve_rand_saturation = BKE_curvemapping_add(
+ 1, 0.0f, 0.0f, 1.0f, 1.0f);
+ brush->gpencil_settings->curve_rand_value = BKE_curvemapping_add(
+ 1, 0.0f, 0.0f, 1.0f, 1.0f);
+ }
+ }
+ }
}
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 3015a0e1b8a..f49278f6c17 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -3315,6 +3315,24 @@ static void write_brush(WriteData *wd, Brush *brush, const void *id_address)
if (brush->gpencil_settings->curve_jitter) {
write_curvemapping(wd, brush->gpencil_settings->curve_jitter);
}
+ if (brush->gpencil_settings->curve_rand_pressure) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_rand_pressure);
+ }
+ if (brush->gpencil_settings->curve_rand_strength) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_rand_strength);
+ }
+ if (brush->gpencil_settings->curve_rand_uv) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_rand_uv);
+ }
+ if (brush->gpencil_settings->curve_rand_hue) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_rand_hue);
+ }
+ if (brush->gpencil_settings->curve_rand_saturation) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_rand_saturation);
+ }
+ if (brush->gpencil_settings->curve_rand_value) {
+ write_curvemapping(wd, brush->gpencil_settings->curve_rand_value);
+ }
}
if (brush->gradient) {
writestruct(wd, DATA, ColorBand, 1, brush->gradient);
diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c b/source/blender/draw/intern/draw_cache_impl_gpencil.c
index 547a9a54b55..62ce34fe556 100644
--- a/source/blender/draw/intern/draw_cache_impl_gpencil.c
+++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c
@@ -544,7 +544,7 @@ static void gpencil_sbuffer_stroke_ensure(bGPdata *gpd, bool do_stroke, bool do_
ED_gpencil_tpoint_to_point(region, origin, &tpoints[i], &gps->points[i]);
mul_m4_v3(ob->imat, &gps->points[i].x);
bGPDspoint *pt = &gps->points[i];
- copy_v4_v4(pt->vert_color, gpd->runtime.vert_color);
+ copy_v4_v4(pt->vert_color, tpoints[i].vert_color);
}
/* Calc uv data along the stroke. */
BKE_gpencil_stroke_uv_update(gps);
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index a3f6e10ccb0..cf433f70e69 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -1152,7 +1152,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
pt->time = 0.0f;
/* Apply the vertex color to point. */
- ED_gpencil_point_vertex_color_set(ts, brush, pt);
+ ED_gpencil_point_vertex_color_set(ts, brush, pt, NULL);
if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) {
MDeformWeight *dw = BKE_defvert_ensure_index(dvert, def_nr);
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 19b53d0662d..a98ccb1cba6 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -68,6 +68,17 @@ struct PropertyRNA;
/* Internal Operator-State Data ------------------------ */
+/** Random settings by stroke */
+typedef struct GpRandomSettings {
+ /** Pressure used for evaluated curves. */
+ float pen_press;
+
+ float hsv[3];
+ float pressure;
+ float strength;
+ float uv;
+} GpRandomSettings;
+
/* Temporary draw data (no draw manager mode) */
typedef struct tGPDdraw {
struct RegionView3D *rv3d; /* region to draw */
@@ -230,6 +241,10 @@ typedef struct tGPDprimitive {
/** size in pixels for uv calculation */
float totpixlen;
+
+ /** Random settings by stroke */
+ GpRandomSettings random_settings;
+
} tGPDprimitive;
/* Modal Operator Drawing Callbacks ------------------------ */
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 961c4e05a28..cb72553c68b 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -255,6 +255,10 @@ typedef struct tGPsdata {
tGPguide guide;
ReportList *reports;
+
+ /** Random settings by stroke */
+ GpRandomSettings random_settings;
+
} tGPsdata;
/* ------ */
@@ -687,6 +691,78 @@ static void gp_smooth_segment(bGPdata *gpd, const float inf, int from_idx, int t
}
}
+static void gp_apply_randomness(tGPsdata *p,
+ BrushGpencilSettings *brush_settings,
+ tGPspoint *pt,
+ const bool press,
+ const bool strength,
+ const bool uv)
+{
+ bGPdata *gpd = p->gpd;
+ GpRandomSettings random_settings = p->random_settings;
+ float value = 0.0f;
+ /* Apply randomness to pressure. */
+ if ((brush_settings->draw_random_press > 0.0f) && (press)) {
+ if ((brush_settings->flag2 & GP_BRUSH_USE_PRESS_AT_STROKE) == 0) {
+ float rand = BLI_rng_get_float(p->rng) * 2.0f - 1.0f;
+ value = 1.0 + rand * 2.0 * brush_settings->draw_random_press;
+ }
+ else {
+ value = 1.0 + random_settings.pressure * brush_settings->draw_random_press;
+ }
+
+ /* Apply random curve. */
+ if (brush_settings->flag2 & GP_BRUSH_USE_PRESSURE_RAND_PRESS) {
+ value *= BKE_curvemapping_evaluateF(
+ brush_settings->curve_rand_pressure, 0, random_settings.pen_press);
+ }
+
+ pt->pressure *= value;
+ CLAMP(pt->pressure, 0.1f, 1.0f);
+ }
+
+ /* Apply randomness to color strength. */
+ if ((brush_settings->draw_random_strength) && (strength)) {
+ if ((brush_settings->flag2 & GP_BRUSH_USE_STRENGTH_AT_STROKE) == 0) {
+ float rand = BLI_rng_get_float(p->rng) * 2.0f - 1.0f;
+ value = 1.0 + rand * brush_settings->draw_random_strength;
+ }
+ else {
+ value = 1.0 + random_settings.strength * brush_settings->draw_random_strength;
+ }
+
+ /* Apply random curve. */
+ if (brush_settings->flag2 & GP_BRUSH_USE_STRENGTH_RAND_PRESS) {
+ value *= BKE_curvemapping_evaluateF(
+ brush_settings->curve_rand_pressure, 0, random_settings.pen_press);
+ }
+
+ pt->strength *= value;
+ CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
+ }
+
+ /* Apply randomness to uv texture rotation. */
+ if ((brush_settings->uv_random > 0.0f) && (uv)) {
+ if ((brush_settings->flag2 & GP_BRUSH_USE_UV_AT_STROKE) == 0) {
+ float rand = BLI_hash_int_01(BLI_hash_int_2d((int)pt->x, gpd->runtime.sbuffer_used)) * 2.0f -
+ 1.0f;
+ value = rand * M_PI_2 * brush_settings->uv_random;
+ }
+ else {
+ value = random_settings.uv * M_PI_2 * brush_settings->uv_random;
+ }
+
+ /* Apply random curve. */
+ if (brush_settings->flag2 & GP_BRUSH_USE_UV_RAND_PRESS) {
+ value *= BKE_curvemapping_evaluateF(
+ brush_settings->curve_rand_uv, 0, random_settings.pen_press);
+ }
+
+ pt->uv_rot += value;
+ CLAMP(pt->uv_rot, -M_PI_2, M_PI_2);
+ }
+}
+
/* add current stroke-point to buffer (returns whether point was successfully added) */
static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure, double curtime)
{
@@ -744,10 +820,6 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
return GP_STROKEADD_INVALID;
}
- /* Set vertex colors for buffer. */
- ED_gpencil_sbuffer_vertex_color_set(
- p->depsgraph, p->ob, p->scene->toolsettings, p->brush, p->material);
-
/* get pointer to destination point */
pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_used);
@@ -768,6 +840,15 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
}
+ /* Set vertex colors for buffer. */
+ ED_gpencil_sbuffer_vertex_color_set(p->depsgraph,
+ p->ob,
+ p->scene->toolsettings,
+ p->brush,
+ p->material,
+ p->random_settings.hsv,
+ p->random_settings.pen_press);
+
if (brush_settings->flag & GP_BRUSH_GROUP_RANDOM) {
/* Apply jitter to position */
if (brush_settings->draw_jitter > 0.0f) {
@@ -781,26 +862,9 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
const float fac = rand * square_f(exp_factor) * jitpress;
gp_brush_jitter(gpd, pt, fac);
}
- /* apply randomness to pressure */
- if (brush_settings->draw_random_press > 0.0f) {
- float rand = BLI_rng_get_float(p->rng) * 2.0f - 1.0f;
- pt->pressure *= 1.0 + rand * 2.0 * brush_settings->draw_random_press;
- CLAMP(pt->pressure, GPENCIL_STRENGTH_MIN, 1.0f);
- }
- /* apply randomness to uv texture rotation */
- if (brush_settings->uv_random > 0.0f) {
- float rand = BLI_hash_int_01(BLI_hash_int_2d((int)pt->x, gpd->runtime.sbuffer_used)) *
- 2.0f -
- 1.0f;
- pt->uv_rot += rand * M_PI_2 * brush_settings->uv_random;
- CLAMP(pt->uv_rot, -M_PI_2, M_PI_2);
- }
- /* apply randomness to color strength */
- if (brush_settings->draw_random_strength) {
- float rand = BLI_rng_get_float(p->rng) * 2.0f - 1.0f;
- pt->strength *= 1.0 + rand * brush_settings->draw_random_strength;
- CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
- }
+
+ /* Apply other randomness. */
+ gp_apply_randomness(p, brush_settings, pt, true, true, true);
}
/* apply angle of stroke to brush size */
@@ -959,9 +1023,10 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
pt->pressure = ptc->pressure;
pt->strength = ptc->strength;
CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
+ copy_v4_v4(pt->vert_color, ptc->vert_color);
pt->time = ptc->time;
/* Apply the vertex color to point. */
- ED_gpencil_point_vertex_color_set(ts, brush, pt);
+ ED_gpencil_point_vertex_color_set(ts, brush, pt, ptc);
pt++;
@@ -994,7 +1059,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
pt->time = ptc->time;
/* Apply the vertex color to point. */
- ED_gpencil_point_vertex_color_set(ts, brush, pt);
+ ED_gpencil_point_vertex_color_set(ts, brush, pt, ptc);
if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) {
BKE_gpencil_dvert_ensure(gps);
@@ -1113,11 +1178,12 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
pt->pressure = ptc->pressure;
pt->strength = ptc->strength;
CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
+ copy_v4_v4(pt->vert_color, ptc->vert_color);
pt->time = ptc->time;
pt->uv_fac = ptc->uv_fac;
pt->uv_rot = ptc->uv_rot;
/* Apply the vertex color to point. */
- ED_gpencil_point_vertex_color_set(ts, brush, pt);
+ ED_gpencil_point_vertex_color_set(ts, brush, pt, ptc);
if (dvert != NULL) {
dvert->totweight = 0;
@@ -1751,10 +1817,16 @@ static void gp_init_drawing_brush(bContext *C, tGPsdata *p)
BKE_brush_gpencil_paint_presets(bmain, ts);
changed = true;
}
- /* be sure curves are initializated */
+ /* Be sure curves are initializated. */
BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_sensitivity);
BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_strength);
BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_jitter);
+ BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_pressure);
+ BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_strength);
+ BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_uv);
+ BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_hue);
+ BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_saturation);
+ BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_rand_value);
/* assign to temp tGPsdata */
p->brush = paint->brush;
@@ -2700,6 +2772,8 @@ static void gpencil_draw_apply_event(bContext *C,
/* handle pressure sensitivity (which is supplied by tablets or otherwise 1.0) */
p->pressure = event->tablet.pressure;
+ /* By default use pen pressure for random curves but attenuated. */
+ p->random_settings.pen_press = pow(p->pressure, 3.0f);
/* Hack for pressure sensitive eraser on D+RMB when using a tablet:
* The pen has to float over the tablet surface, resulting in
@@ -3052,6 +3126,8 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
else {
p = op->customdata;
}
+ /* Init random settings. */
+ ED_gpencil_init_random_settings(p->brush, event->mval, &p->random_settings);
/* TODO: set any additional settings that we can take from the events?
* if eraser is on, draw radial aid */
@@ -3175,10 +3251,17 @@ static void gp_brush_angle_segment(tGPsdata *p, tGPspoint *pt_prev, tGPspoint *p
static void gpencil_add_arc_points(tGPsdata *p, float mval[2], int segments)
{
bGPdata *gpd = p->gpd;
+ BrushGpencilSettings *brush_settings = p->brush->gpencil_settings;
+
if (gpd->runtime.sbuffer_used < 3) {
+ tGPspoint *points = (tGPspoint *)gpd->runtime.sbuffer;
+ /* Apply other randomness to first points. */
+ for (int i = 0; i < gpd->runtime.sbuffer_used; i++) {
+ tGPspoint *pt = &points[i];
+ gp_apply_randomness(p, brush_settings, pt, false, false, true);
+ }
return;
}
- BrushGpencilSettings *brush_settings = p->brush->gpencil_settings;
int idx_prev = gpd->runtime.sbuffer_used;
/* Add space for new arc points. */
@@ -3233,6 +3316,7 @@ static void gpencil_add_arc_points(tGPsdata *p, float mval[2], int segments)
corner[0] = midpoint[0] - (cp1[0] - midpoint[0]);
corner[1] = midpoint[1] - (cp1[1] - midpoint[1]);
+ float stepcolor = 1.0f / segments;
tGPspoint *pt_step = pt_prev;
for (int i = 0; i < segments; i++) {
@@ -3243,6 +3327,9 @@ static void gpencil_add_arc_points(tGPsdata *p, float mval[2], int segments)
/* Set pressure and strength equals to previous. It will be smoothed later. */
pt->pressure = pt_prev->pressure;
pt->strength = pt_prev->strength;
+ /* Interpolate vertex color. */
+ interp_v4_v4v4(
+ pt->vert_color, pt_before->vert_color, pt_prev->vert_color, stepcolor * (i + 1));
/* Apply angle of stroke to brush size to interpolated points but slightly attenuated.. */
if (brush_settings->draw_angle_factor != 0.0f) {
@@ -3252,26 +3339,8 @@ static void gpencil_add_arc_points(tGPsdata *p, float mval[2], int segments)
pt_step = pt;
}
- /* Apply randomness to pressure. */
- if (brush_settings->draw_random_press > 0.0f) {
- float rand = BLI_rng_get_float(p->rng) * 2.0f - 1.0f;
- pt->pressure *= 1.0 + rand * 2.0 * brush_settings->draw_random_press;
- CLAMP(pt->pressure, GPENCIL_STRENGTH_MIN, 1.0f);
- }
- /* Apply randomness to color strength. */
- if (brush_settings->draw_random_strength) {
- float rand = BLI_rng_get_float(p->rng) * 2.0f - 1.0f;
- pt->strength *= 1.0 + rand * brush_settings->draw_random_strength;
- CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
- }
- /* Apply randomness to uv texture rotation. */
- if (brush_settings->uv_random > 0.0f) {
- float rand = BLI_hash_int_01(BLI_hash_int_2d((int)pt->x, gpd->runtime.sbuffer_used + i)) *
- 2.0f -
- 1.0f;
- pt->uv_rot += rand * M_PI_2 * brush_settings->uv_random;
- CLAMP(pt->uv_rot, -M_PI_2, M_PI_2);
- }
+ /* Apply other randomness. */
+ gp_apply_randomness(p, brush_settings, pt, false, false, true);
a += step;
}
@@ -3323,6 +3392,7 @@ static void gpencil_add_guide_points(const tGPsdata *p,
/* Set pressure and strength equals to previous. It will be smoothed later. */
pt->pressure = pt_before->pressure;
pt->strength = pt_before->strength;
+ copy_v4_v4(pt->vert_color, pt_before->vert_color);
}
}
else {
@@ -3339,6 +3409,7 @@ static void gpencil_add_guide_points(const tGPsdata *p,
/* Set pressure and strength equals to previous. It will be smoothed later. */
pt->pressure = pt_before->pressure;
pt->strength = pt_before->strength;
+ copy_v4_v4(pt->vert_color, pt_before->vert_color);
}
}
}
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 11aeeba5a24..1778162c1a3 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -124,8 +124,13 @@ static void gp_session_validatebuffer(tGPDprimitive *p)
gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
/* Set vertex colors for buffer. */
- ED_gpencil_sbuffer_vertex_color_set(
- p->depsgraph, p->ob, p->scene->toolsettings, p->brush, p->material);
+ ED_gpencil_sbuffer_vertex_color_set(p->depsgraph,
+ p->ob,
+ p->scene->toolsettings,
+ p->brush,
+ p->material,
+ p->random_settings.hsv,
+ 1.0f);
if (ELEM(p->type, GP_STROKE_BOX, GP_STROKE_CIRCLE)) {
gpd->runtime.sbuffer_sflag |= GP_STROKE_CYCLIC;
@@ -681,6 +686,8 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
ToolSettings *ts = tgpi->scene->toolsettings;
bGPdata *gpd = tgpi->gpd;
Brush *brush = tgpi->brush;
+ BrushGpencilSettings *brush_settings = brush->gpencil_settings;
+ GpRandomSettings random_settings = tgpi->random_settings;
bGPDstroke *gps = tgpi->gpf->strokes.first;
GP_Sculpt_Settings *gset = &ts->gp_sculpt;
int depth_margin = (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 4 : 0;
@@ -735,11 +742,11 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
if (gset->flag & GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE) {
BKE_curvemapping_initialize(ts->gp_sculpt.cur_primitive);
}
- if (tgpi->brush->gpencil_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) {
- BKE_curvemapping_initialize(tgpi->brush->gpencil_settings->curve_jitter);
+ if (brush_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) {
+ BKE_curvemapping_initialize(brush_settings->curve_jitter);
}
- if (tgpi->brush->gpencil_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) {
- BKE_curvemapping_initialize(tgpi->brush->gpencil_settings->curve_strength);
+ if (brush_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) {
+ BKE_curvemapping_initialize(brush_settings->curve_strength);
}
/* get an array of depths, far depths are blended */
@@ -841,10 +848,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
tGPspoint *p2d = &points2D[i];
/* set rnd value for reuse */
- if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) && (p2d->rnd_dirty != true)) {
+ if ((brush_settings->flag & GP_BRUSH_GROUP_RANDOM) && (p2d->rnd_dirty != true)) {
p2d->rnd[0] = BLI_rng_get_float(tgpi->rng);
p2d->rnd[1] = BLI_rng_get_float(tgpi->rng);
- p2d->rnd[2] = BLI_rng_get_float(tgpi->rng);
p2d->rnd_dirty = true;
}
@@ -858,7 +864,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
/* calc pressure */
float curve_pressure = 1.0;
float pressure = 1.0;
- float strength = brush->gpencil_settings->draw_strength;
+ float strength = brush_settings->draw_strength;
/* normalize value to evaluate curve */
if (gset->flag & GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE) {
@@ -868,20 +874,18 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
}
/* apply jitter to position */
- if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) &&
- (brush->gpencil_settings->draw_jitter > 0.0f)) {
+ if ((brush_settings->flag & GP_BRUSH_GROUP_RANDOM) && (brush_settings->draw_jitter > 0.0f)) {
float jitter;
- if (brush->gpencil_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) {
- jitter = BKE_curvemapping_evaluateF(
- brush->gpencil_settings->curve_jitter, 0, curve_pressure);
+ if (brush_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) {
+ jitter = BKE_curvemapping_evaluateF(brush_settings->curve_jitter, 0, curve_pressure);
}
else {
- jitter = brush->gpencil_settings->draw_jitter;
+ jitter = brush_settings->draw_jitter;
}
/* exponential value */
- const float exfactor = square_f(brush->gpencil_settings->draw_jitter + 2.0f);
+ const float exfactor = square_f(brush_settings->draw_jitter + 2.0f);
const float fac = p2d->rnd[0] * exfactor * jitter;
/* vector */
@@ -906,47 +910,68 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
add_v2_v2(&p2d->x, svec);
}
- /* apply randomness to pressure */
- if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) &&
- (brush->gpencil_settings->draw_random_press > 0.0f)) {
- if (p2d->rnd[0] > 0.5f) {
- pressure -= (brush->gpencil_settings->draw_random_press * 2.0f) * p2d->rnd[1];
- }
- else {
- pressure += (brush->gpencil_settings->draw_random_press * 2.0f) * p2d->rnd[2];
- }
- }
-
/* color strength */
- if (brush->gpencil_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) {
- float curvef = BKE_curvemapping_evaluateF(
- brush->gpencil_settings->curve_strength, 0, curve_pressure);
+ if (brush_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) {
+ float curvef = BKE_curvemapping_evaluateF(brush_settings->curve_strength, 0, curve_pressure);
strength *= curvef;
- strength *= brush->gpencil_settings->draw_strength;
+ strength *= brush_settings->draw_strength;
}
CLAMP(strength, GPENCIL_STRENGTH_MIN, 1.0f);
- /* apply randomness to color strength */
- if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) &&
- (brush->gpencil_settings->draw_random_strength > 0.0f)) {
- if (p2d->rnd[2] > 0.5f) {
- strength -= strength * brush->gpencil_settings->draw_random_strength * p2d->rnd[0];
+ if (brush_settings->flag & GP_BRUSH_GROUP_RANDOM) {
+ /* Apply randomness to pressure. */
+ if (brush_settings->draw_random_press > 0.0f) {
+ if ((brush_settings->flag2 & GP_BRUSH_USE_PRESS_AT_STROKE) == 0) {
+ float rand = BLI_rng_get_float(tgpi->rng) * 2.0f - 1.0f;
+ pressure *= 1.0 + rand * 2.0 * brush_settings->draw_random_press;
+ }
+ else {
+ pressure *= 1.0 + random_settings.pressure * brush_settings->draw_random_press;
+ }
+
+ /* Apply random curve. */
+ if (brush_settings->flag2 & GP_BRUSH_USE_PRESSURE_RAND_PRESS) {
+ pressure *= BKE_curvemapping_evaluateF(brush_settings->curve_rand_pressure, 0, pressure);
+ }
+
+ CLAMP(pressure, 0.1f, 1.0f);
}
- else {
- strength += strength * brush->gpencil_settings->draw_random_strength * p2d->rnd[1];
+
+ /* Apply randomness to color strength. */
+ if (brush_settings->draw_random_strength) {
+ if ((brush_settings->flag2 & GP_BRUSH_USE_STRENGTH_AT_STROKE) == 0) {
+ float rand = BLI_rng_get_float(tgpi->rng) * 2.0f - 1.0f;
+ strength *= 1.0 + rand * brush_settings->draw_random_strength;
+ }
+ else {
+ strength *= 1.0 + random_settings.strength * brush_settings->draw_random_strength;
+ }
+
+ /* Apply random curve. */
+ if (brush_settings->flag2 & GP_BRUSH_USE_STRENGTH_RAND_PRESS) {
+ strength *= BKE_curvemapping_evaluateF(brush_settings->curve_rand_strength, 0, pressure);
+ }
+
+ CLAMP(strength, GPENCIL_STRENGTH_MIN, 1.0f);
}
- CLAMP(strength, GPENCIL_STRENGTH_MIN, 1.0f);
}
copy_v2_v2(&tpt->x, &p2d->x);
- CLAMP_MIN(pressure, 0.1f);
-
tpt->pressure = pressure;
tpt->strength = strength;
tpt->time = p2d->time;
+ /* Set vertex colors for buffer. */
+ ED_gpencil_sbuffer_vertex_color_set(tgpi->depsgraph,
+ tgpi->ob,
+ tgpi->scene->toolsettings,
+ tgpi->brush,
+ tgpi->material,
+ tgpi->random_settings.hsv,
+ strength);
+
/* point uv */
if (gpd->runtime.sbuffer_used > 0) {
tGPspoint *tptb = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1;
@@ -994,8 +1019,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
pt->time = 0.0f;
pt->flag = 0;
pt->uv_fac = tpt->uv_fac;
- /* Apply the vertex color to point. */
- ED_gpencil_point_vertex_color_set(ts, brush, pt);
+ copy_v4_v4(pt->vert_color, tpt->vert_color);
if (gps->dvert != NULL) {
MDeformVert *dvert = &gps->dvert[i];
@@ -1159,6 +1183,7 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
/* Set Draw brush. */
Brush *brush = BKE_paint_toolslots_brush_get(paint, 0);
+
BKE_brush_tool_set(brush, paint, 0);
BKE_paint_brush_set(paint, brush);
tgpi->brush = brush;
@@ -1226,6 +1251,9 @@ static int gpencil_primitive_invoke(bContext *C, wmOperator *op, const wmEvent *
gpencil_primitive_init(C, op);
tgpi = op->customdata;
+ /* Init random settings. */
+ ED_gpencil_init_random_settings(tgpi->brush, event->mval, &tgpi->random_settings);
+
const bool is_modal = RNA_boolean_get(op->ptr, "wait_for_input");
if (!is_modal) {
tgpi->flag = IN_PROGRESS;
@@ -1262,6 +1290,7 @@ static void gpencil_primitive_interaction_end(bContext *C,
ToolSettings *ts = tgpi->scene->toolsettings;
Brush *brush = tgpi->brush;
+ BrushGpencilSettings *brush_settings = brush->gpencil_settings;
const int def_nr = tgpi->ob->actdef - 1;
const bool have_weight = (bool)BLI_findlink(&tgpi->ob->defbase, def_nr);
@@ -1285,8 +1314,8 @@ static void gpencil_primitive_interaction_end(bContext *C,
gps = tgpi->gpf->strokes.first;
if (gps) {
gps->thickness = brush->size;
- gps->hardeness = brush->gpencil_settings->hardeness;
- copy_v2_v2(gps->aspect_ratio, brush->gpencil_settings->aspect_ratio);
+ gps->hardeness = brush_settings->hardeness;
+ copy_v2_v2(gps->aspect_ratio, brush_settings->aspect_ratio);
/* Calc geometry data. */
BKE_gpencil_stroke_geometry_update(gps);
@@ -1449,23 +1478,25 @@ static void gpencil_primitive_edit_event_handling(
static void gpencil_primitive_strength(tGPDprimitive *tgpi, bool reset)
{
Brush *brush = tgpi->brush;
+ BrushGpencilSettings *brush_settings = brush->gpencil_settings;
+
if (brush) {
if (reset) {
- brush->gpencil_settings->draw_strength = tgpi->brush_strength;
+ brush_settings->draw_strength = tgpi->brush_strength;
tgpi->brush_strength = 0.0f;
}
else {
if (tgpi->brush_strength == 0.0f) {
- tgpi->brush_strength = brush->gpencil_settings->draw_strength;
+ tgpi->brush_strength = brush_settings->draw_strength;
}
float move[2];
sub_v2_v2v2(move, tgpi->mval, tgpi->mvalo);
float adjust = (move[1] > 0.0f) ? 0.01f : -0.01f;
- brush->gpencil_settings->draw_strength += adjust * fabsf(len_manhattan_v2(move));
+ brush_settings->draw_strength += adjust * fabsf(len_manhattan_v2(move));
}
/* limit low limit because below 0.2f the stroke is invisible */
- CLAMP(brush->gpencil_settings->draw_strength, 0.2f, 1.0f);
+ CLAMP(brush_settings->draw_strength, 0.2f, 1.0f);
}
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 6a7bb2012a7..6b18117cf8a 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -30,11 +30,14 @@
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
+#include "BLI_hash.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
+#include "PIL_time.h"
+
#include "DNA_brush_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
@@ -74,6 +77,7 @@
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
+#include "ED_transform_snap_object_context.h"
#include "ED_view3d.h"
#include "GPU_immediate.h"
@@ -2559,26 +2563,170 @@ void ED_gpencil_fill_vertex_color_set(ToolSettings *ts, Brush *brush, bGPDstroke
}
}
-void ED_gpencil_point_vertex_color_set(ToolSettings *ts, Brush *brush, bGPDspoint *pt)
+void ED_gpencil_point_vertex_color_set(ToolSettings *ts,
+ Brush *brush,
+ bGPDspoint *pt,
+ tGPspoint *tpt)
{
if (GPENCIL_USE_VERTEX_COLOR_STROKE(ts, brush)) {
- copy_v3_v3(pt->vert_color, brush->rgb);
- pt->vert_color[3] = brush->gpencil_settings->vertex_factor;
- srgb_to_linearrgb_v4(pt->vert_color, pt->vert_color);
+ if (tpt == NULL) {
+ copy_v3_v3(pt->vert_color, brush->rgb);
+ pt->vert_color[3] = brush->gpencil_settings->vertex_factor;
+ srgb_to_linearrgb_v4(pt->vert_color, pt->vert_color);
+ }
+ else {
+ copy_v3_v3(pt->vert_color, tpt->vert_color);
+ pt->vert_color[3] = brush->gpencil_settings->vertex_factor;
+ }
}
else {
zero_v4(pt->vert_color);
}
}
-void ED_gpencil_sbuffer_vertex_color_set(
- Depsgraph *depsgraph, Object *ob, ToolSettings *ts, Brush *brush, Material *material)
+void ED_gpencil_init_random_settings(Brush *brush,
+ const int mval[2],
+ GpRandomSettings *random_settings)
+{
+ int seed = ((uint)(ceil(PIL_check_seconds_timer())) + 1) % 128;
+ /* Use mouse position to get randomness. */
+ int ix = mval[0] * seed;
+ int iy = mval[1] * seed;
+ int iz = ix + iy * seed;
+ zero_v3(random_settings->hsv);
+
+ BrushGpencilSettings *brush_settings = brush->gpencil_settings;
+ /* Random to Hue. */
+ if (brush_settings->random_hue > 0.0f) {
+ float rand = BLI_hash_int_01(BLI_hash_int_2d(ix, iy)) * 2.0f - 1.0f;
+ random_settings->hsv[0] = rand * brush_settings->random_hue * 0.5f;
+ }
+ /* Random to Saturation. */
+ if (brush_settings->random_saturation > 0.0f) {
+ float rand = BLI_hash_int_01(BLI_hash_int_2d(iy, ix)) * 2.0f - 1.0f;
+ random_settings->hsv[1] = rand * brush_settings->random_saturation;
+ }
+ /* Random to Value. */
+ if (brush_settings->random_value > 0.0f) {
+ float rand = BLI_hash_int_01(BLI_hash_int_2d(ix * iz, iy * iz)) * 2.0f - 1.0f;
+ random_settings->hsv[2] = rand * brush_settings->random_value;
+ }
+
+ /* Random to pressure. */
+ if (brush_settings->draw_random_press > 0.0f) {
+ random_settings->pressure = BLI_hash_int_01(BLI_hash_int_2d(ix + iz, iy + iz)) * 2.0f - 1.0f;
+ }
+
+ /* Randomn to color strength. */
+ if (brush_settings->draw_random_strength) {
+ random_settings->strength = BLI_hash_int_01(BLI_hash_int_2d(ix + iy, iy + iz + ix)) * 2.0f -
+ 1.0f;
+ }
+
+ /* Random to uv texture rotation. */
+ if (brush_settings->uv_random > 0.0f) {
+ random_settings->uv = BLI_hash_int_01(BLI_hash_int_2d(iy + iz, ix * iz)) * 2.0f - 1.0f;
+ }
+}
+
+static void gpencil_sbuffer_vertex_color_random(
+ bGPdata *gpd, Brush *brush, tGPspoint *tpt, float random_color[3], float pen_pressure)
+{
+ BrushGpencilSettings *brush_settings = brush->gpencil_settings;
+ if (brush_settings->flag & GP_BRUSH_GROUP_RANDOM) {
+ int seed = ((uint)(ceil(PIL_check_seconds_timer())) + 1) % 128;
+
+ int ix = (int)(tpt->x * seed);
+ int iy = (int)(tpt->y * seed);
+ int iz = ix + iy * seed;
+ float hsv[3];
+ float factor_value[3];
+ zero_v3(factor_value);
+
+ /* Apply randomness to Hue. */
+ if (brush_settings->random_hue > 0.0f) {
+ if ((brush_settings->flag2 & GP_BRUSH_USE_HUE_AT_STROKE) == 0) {
+
+ float rand = BLI_hash_int_01(BLI_hash_int_2d(ix, gpd->runtime.sbuffer_used)) * 2.0f - 1.0f;
+ factor_value[0] = rand * brush_settings->random_hue * 0.5f;
+ }
+ else {
+ factor_value[0] = random_color[0];
+ }
+
+ /* Apply random curve. */
+ if (brush_settings->flag2 & GP_BRUSH_USE_HUE_RAND_PRESS) {
+ factor_value[0] *= BKE_curvemapping_evaluateF(
+ brush_settings->curve_rand_hue, 0, pen_pressure);
+ }
+ }
+
+ /* Apply randomness to Saturation. */
+ if (brush_settings->random_saturation > 0.0f) {
+ if ((brush_settings->flag2 & GP_BRUSH_USE_SAT_AT_STROKE) == 0) {
+ float rand = BLI_hash_int_01(BLI_hash_int_2d(iy, gpd->runtime.sbuffer_used)) * 2.0f - 1.0f;
+ factor_value[1] = rand * brush_settings->random_saturation;
+ }
+ else {
+ factor_value[1] = random_color[1];
+ }
+
+ /* Apply random curve. */
+ if (brush_settings->flag2 & GP_BRUSH_USE_SAT_RAND_PRESS) {
+ factor_value[1] *= BKE_curvemapping_evaluateF(
+ brush_settings->curve_rand_saturation, 0, pen_pressure);
+ }
+ }
+
+ /* Apply randomness to Value. */
+ if (brush_settings->random_value > 0.0f) {
+ if ((brush_settings->flag2 & GP_BRUSH_USE_VAL_AT_STROKE) == 0) {
+ float rand = BLI_hash_int_01(BLI_hash_int_2d(iz, gpd->runtime.sbuffer_used)) * 2.0f - 1.0f;
+ factor_value[2] = rand * brush_settings->random_value;
+ }
+ else {
+ factor_value[2] = random_color[2];
+ }
+
+ /* Apply random curve. */
+ if (brush_settings->flag2 & GP_BRUSH_USE_VAL_RAND_PRESS) {
+ factor_value[2] *= BKE_curvemapping_evaluateF(
+ brush_settings->curve_rand_value, 0, pen_pressure);
+ }
+ }
+
+ rgb_to_hsv_v(tpt->vert_color, hsv);
+ add_v3_v3(hsv, factor_value);
+ /* For Hue need to cover all range, but for Saturation and Value
+ * is not logic because the effect is too hard, so the value is just clamped. */
+ if (hsv[0] < 0.0f) {
+ hsv[0] += 1.0f;
+ }
+ else if (hsv[0] > 1.0f) {
+ hsv[0] -= 1.0f;
+ }
+
+ CLAMP3(hsv, 0.0f, 1.0f);
+ hsv_to_rgb_v(hsv, tpt->vert_color);
+ }
+}
+
+void ED_gpencil_sbuffer_vertex_color_set(Depsgraph *depsgraph,
+ Object *ob,
+ ToolSettings *ts,
+ Brush *brush,
+ Material *material,
+ float random_color[3],
+ float pen_pressure)
{
bGPdata *gpd = (bGPdata *)ob->data;
Object *ob_eval = (Object *)DEG_get_evaluated_id(depsgraph, &ob->id);
bGPdata *gpd_eval = (bGPdata *)ob_eval->data;
MaterialGPencilStyle *gp_style = material->gp_style;
+ int idx = gpd->runtime.sbuffer_used;
+ tGPspoint *tpt = (tGPspoint *)gpd->runtime.sbuffer + idx;
+
float vertex_color[4];
copy_v3_v3(vertex_color, brush->rgb);
vertex_color[3] = brush->gpencil_settings->vertex_factor;
@@ -2593,15 +2741,18 @@ void ED_gpencil_sbuffer_vertex_color_set(
}
/* Copy stroke vertex color. */
if (GPENCIL_USE_VERTEX_COLOR_STROKE(ts, brush)) {
- copy_v4_v4(gpd->runtime.vert_color, vertex_color);
+ copy_v4_v4(tpt->vert_color, vertex_color);
}
else {
- copy_v4_v4(gpd->runtime.vert_color, gp_style->stroke_rgba);
+ copy_v4_v4(tpt->vert_color, gp_style->stroke_rgba);
}
- /* Copy to eval data because paint operators don't tag refresh until end for speedup painting. */
+ /* Random Color. */
+ gpencil_sbuffer_vertex_color_random(gpd, brush, tpt, random_color, pen_pressure);
+
+ /* Copy to eval data because paint operators don't tag refresh until end for speedup
+ painting. */
if (gpd_eval != NULL) {
- copy_v4_v4(gpd_eval->runtime.vert_color, gpd->runtime.vert_color);
copy_v4_v4(gpd_eval->runtime.vert_color_fill, gpd->runtime.vert_color_fill);
gpd_eval->runtime.matid = gpd->runtime.matid;
}
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 1403ae1f3cc..2dbd979564e 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -40,6 +40,7 @@ struct bGPDspoint;
struct bGPDstroke;
struct bGPdata;
struct tGPspoint;
+struct GpRandomSettings;
struct ARegion;
struct Depsgraph;
@@ -48,6 +49,7 @@ struct RegionView3D;
struct ReportList;
struct Scene;
struct ScrArea;
+struct SnapObjectContext;
struct ToolSettings;
struct View3D;
struct ViewLayer;
@@ -69,14 +71,15 @@ struct wmOperator;
* Used as part of the 'stroke cache' used during drawing of new strokes
*/
typedef struct tGPspoint {
- float x, y; /* x and y coordinates of cursor (in relative to area) */
- float pressure; /* pressure of tablet at this point */
- float strength; /* pressure of tablet at this point for alpha factor */
- float time; /* Time relative to stroke start (used when converting to path) */
- float uv_fac; /* factor of uv along the stroke */
- float uv_rot; /* uv rotation for dor mode */
- float rnd[3]; /* rnd value */
- bool rnd_dirty; /* rnd flag */
+ float x, y; /* x and y coordinates of cursor (in relative to area) */
+ float pressure; /* pressure of tablet at this point */
+ float strength; /* pressure of tablet at this point for alpha factor */
+ float time; /* Time relative to stroke start (used when converting to path) */
+ float uv_fac; /* factor of uv along the stroke */
+ float uv_rot; /* uv rotation for dor mode */
+ float rnd[3]; /* rnd value */
+ bool rnd_dirty; /* rnd flag */
+ float vert_color[4]; /* Point vertex color. */
} tGPspoint;
/* ----------- Grease Pencil Tools/Context ------------- */
@@ -296,12 +299,18 @@ void ED_gpencil_fill_vertex_color_set(struct ToolSettings *ts,
struct bGPDstroke *gps);
void ED_gpencil_point_vertex_color_set(struct ToolSettings *ts,
struct Brush *brush,
- struct bGPDspoint *pt);
+ struct bGPDspoint *pt,
+ struct tGPspoint *tpt);
void ED_gpencil_sbuffer_vertex_color_set(struct Depsgraph *depsgraph,
struct Object *ob,
struct ToolSettings *ts,
struct Brush *brush,
- struct Material *material);
+ struct Material *material,
+ float random_color[3],
+ float pen_pressure);
+void ED_gpencil_init_random_settings(struct Brush *brush,
+ const int mval[2],
+ struct GpRandomSettings *random_settings);
bool ED_gpencil_stroke_check_collision(struct GP_SpaceConversion *gsc,
struct bGPDstroke *gps,
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 0e16abf76f7..c143c2a442a 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -75,7 +75,7 @@ typedef struct BrushGpencilSettings {
short fill_leak;
/** Fill zoom factor */
short fill_factor;
- char _pad1[4];
+ int flag2;
/** Number of simplify steps. */
int fill_simplylvl;
@@ -118,11 +118,24 @@ typedef struct BrushGpencilSettings {
int sculpt_mode_flag;
/** Preset type (used to reset brushes - internal). */
short preset_type;
- char _pad3[6];
+ char _pad3[2];
+
+ /** Randomness for Hue. */
+ float random_hue;
+ /** Randomness for Saturation. */
+ float random_saturation;
+ /** Randomness for Value. */
+ float random_value;
struct CurveMapping *curve_sensitivity;
struct CurveMapping *curve_strength;
struct CurveMapping *curve_jitter;
+ struct CurveMapping *curve_rand_pressure;
+ struct CurveMapping *curve_rand_strength;
+ struct CurveMapping *curve_rand_uv;
+ struct CurveMapping *curve_rand_hue;
+ struct CurveMapping *curve_rand_saturation;
+ struct CurveMapping *curve_rand_value;
/* optional link of material to replace default in context */
/** Material. */
@@ -204,6 +217,33 @@ typedef enum eGPDbrush_Flag {
GP_BRUSH_TRIM_STROKE = (1 << 16),
} eGPDbrush_Flag;
+typedef enum eGPDbrush_Flag2 {
+ /* Brush use random Hue at stroke level */
+ GP_BRUSH_USE_HUE_AT_STROKE = (1 << 0),
+ /* Brush use random Saturation at stroke level */
+ GP_BRUSH_USE_SAT_AT_STROKE = (1 << 1),
+ /* Brush use random Value at stroke level */
+ GP_BRUSH_USE_VAL_AT_STROKE = (1 << 2),
+ /* Brush use random Pressure at stroke level */
+ GP_BRUSH_USE_PRESS_AT_STROKE = (1 << 3),
+ /* Brush use random Strength at stroke level */
+ GP_BRUSH_USE_STRENGTH_AT_STROKE = (1 << 4),
+ /* Brush use random UV at stroke level */
+ GP_BRUSH_USE_UV_AT_STROKE = (1 << 5),
+ /* Brush use Hue random pressure */
+ GP_BRUSH_USE_HUE_RAND_PRESS = (1 << 6),
+ /* Brush use Saturation random pressure */
+ GP_BRUSH_USE_SAT_RAND_PRESS = (1 << 7),
+ /* Brush use Value random pressure */
+ GP_BRUSH_USE_VAL_RAND_PRESS = (1 << 8),
+ /* Brush use Pressure random pressure */
+ GP_BRUSH_USE_PRESSURE_RAND_PRESS = (1 << 9),
+ /* Brush use Strength random pressure */
+ GP_BRUSH_USE_STRENGTH_RAND_PRESS = (1 << 10),
+ /* Brush use UV random pressure */
+ GP_BRUSH_USE_UV_RAND_PRESS = (1 << 11),
+} eGPDbrush_Flag2;
+
/* BrushGpencilSettings->gp_fill_draw_mode */
typedef enum eGP_FillDrawModes {
GP_FILL_DMODE_BOTH = 0,
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index cfc9324a100..c3180ae79db 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -520,9 +520,6 @@ typedef struct bGPdata_Runtime {
/** Number of total elements available in cache. */
int sbuffer_size;
- /** Vertex Color applied to point (while drawing). */
- float vert_color[4];
-
/** Vertex Color applied to Fill (while drawing). */
float vert_color_fill[4];
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 2c4e221ca8c..d3b607fcb76 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1296,6 +1296,48 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+ prop = RNA_def_property(srna, "curve_random_pressure", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "curve_rand_pressure");
+ RNA_def_property_struct_type(prop, "CurveMapping");
+ RNA_def_property_ui_text(prop, "Random Curve", "Curve used for modulating effect");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "curve_random_strength", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "curve_rand_strength");
+ RNA_def_property_struct_type(prop, "CurveMapping");
+ RNA_def_property_ui_text(prop, "Random Curve", "Curve used for modulating effect");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "curve_random_uv", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "curve_rand_uv");
+ RNA_def_property_struct_type(prop, "CurveMapping");
+ RNA_def_property_ui_text(prop, "Random Curve", "Curve used for modulating effect");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "curve_random_hue", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "curve_rand_hue");
+ RNA_def_property_struct_type(prop, "CurveMapping");
+ RNA_def_property_ui_text(prop, "Random Curve", "Curve used for modulating effect");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "curve_random_saturation", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "curve_rand_saturation");
+ RNA_def_property_struct_type(prop, "CurveMapping");
+ RNA_def_property_ui_text(prop, "Random Curve", "Curve used for modulating effect");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "curve_random_value", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "curve_rand_value");
+ RNA_def_property_struct_type(prop, "CurveMapping");
+ RNA_def_property_ui_text(prop, "Random Curve", "Curve used for modulating effect");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
/* fill threshold for transparence */
prop = RNA_def_property(srna, "fill_threshold", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "fill_threshold");
@@ -1434,6 +1476,30 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Vertex Color Factor", "Factor used to mix vertex color to get final color");
+ /* Hue randomness. */
+ prop = RNA_def_property(srna, "random_hue_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "random_hue");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_ui_text(prop, "Hue", "Random factor to modify original hue");
+ RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+
+ /* Saturation randomness. */
+ prop = RNA_def_property(srna, "random_saturation_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "random_saturation");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_ui_text(prop, "Saturation", "Random factor to modify original saturation");
+ RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+
+ /* Value randomness. */
+ prop = RNA_def_property(srna, "random_value_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "random_value");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_ui_text(prop, "Value", "Random factor to modify original value");
+ RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+
/* Flags */
prop = RNA_def_property(srna, "use_pressure", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_PRESSURE);
@@ -1457,6 +1523,90 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+ prop = RNA_def_property(srna, "use_stroke_random_hue", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_HUE_AT_STROKE);
+ RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
+ RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "use_stroke_random_sat", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_SAT_AT_STROKE);
+ RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
+ RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "use_stroke_random_val", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_VAL_AT_STROKE);
+ RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
+ RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "use_stroke_random_radius", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_PRESS_AT_STROKE);
+ RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
+ RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "use_stroke_random_strength", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_STRENGTH_AT_STROKE);
+ RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
+ RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "use_stroke_random_uv", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_UV_AT_STROKE);
+ RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0);
+ RNA_def_property_ui_text(prop, "Stroke Random", "Use randomness at stroke level");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "use_random_press_hue", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_HUE_RAND_PRESS);
+ RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
+ RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "use_random_press_sat", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_SAT_RAND_PRESS);
+ RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
+ RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "use_random_press_val", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_VAL_RAND_PRESS);
+ RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
+ RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "use_random_press_radius", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_PRESSURE_RAND_PRESS);
+ RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
+ RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "use_random_press_strength", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_STRENGTH_RAND_PRESS);
+ RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
+ RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ prop = RNA_def_property(srna, "use_random_press_uv", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", GP_BRUSH_USE_UV_RAND_PRESS);
+ RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
+ RNA_def_property_ui_text(prop, "Use Pressure", "Use pressure to modulate randomness");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
prop = RNA_def_property(srna, "use_settings_stabilizer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_STABILIZE_MOUSE);
RNA_def_property_boolean_default(prop, true);