Page MenuHome

Improve grease pencil stroke quality
ClosedPublic

Authored by Antonio Vazquez (antoniov) on Mar 21 2016, 11:07 PM.

Details

Summary

Improve the quality of current grease pencil strokes adding a new dynamic smooth and subdivision. The level of smooth and subdivide can be adjusted using UI parameters. These options are disabled by default in order to keep the grease pencil stroke compatible with any existing add-on.

Both parameters are defined at layer level.

Diff Detail

Repository
rB Blender

Event Timeline

Antonio Vazquez (antoniov) retitled this revision from to Improve grease pencil stroke quality.
Antonio Vazquez (antoniov) updated this object.
Joshua Leung (aligorith) requested changes to this revision.Mar 22 2016, 2:44 PM
Joshua Leung (aligorith) edited edge metadata.
Joshua Leung (aligorith) added inline comments.
release/scripts/startup/bl_ui/properties_grease_pencil_common.py
579

Instead of lumping these settings in with the others settings, I'd probably insert a layout.separator() before adding these. Whether they would then go before or after the "frame-lock" toggle (the big long button) is open to debate.


Perhaps the biggest issue we have with putting these on a per-layer basis, is that it becomes less clear to the user which settings can be tweaked to change the appearance of the stroke after they have been drawn (i.e. everything else), and which settings only apply when drawing the stroke (i.e. these two).

So, maybe these settings should even go in a separate section (same panel for now, but who knows?) below the onion skinning stuff, and then we do:

# ... onion skinning buttons

layout.separator()
layout.separator()
col = layout.column(align=True)
col.label(text="Stroke Quality:")
split = col.split()
split.prop(gpl, "dynamic_smooth")
split.prop(gpl, "subdivision")
source/blender/editors/gpencil/gpencil_paint.c
567

It may be better to find a way to share this code between the smooth brush and here. So, maybe:

  • move this function to gpencil_utils.c as "bool gp_smooth_stroke(bGDstroke *gps, int i, float inf)"
  • add a "bool gp_smooth_stroke(bGDstroke *gps, int i, float inf);" to gpencil_intern.h
  • use "gp_smooth_stroke" in this file
  • simplify the gp_brush_smooth_apply code to:
static bool gp_brush_smooth_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
                                  const int radius, const int co[2])
{
	GP_EditBrush_Data *brush = gso->brush;
	bGPDspoint *pt = &gps->points[i];
	float inf = gp_brush_influence_calc(gso, radius, co);

        /* perform smoothing */
        return gp_smooth_stroke(gps, i, inf);
}
623

"subpoints" is not really that descriptive. It was only upon re-reading the code that I realised that this is the new total number of points in the subdivided stroke. Maybe something like "new_totpoints" or something like that instead?

627

Is there any reason why you need to have these on the stack, and thus end up copying the data back and forth? It would probably be more efficient to just do:

bGPDspoint *pt_a;
bGPDspoint *pt_b;
bGPDspoint *pt_new;

then:

 pt_a = &gps->points[i];
 pt_b = &gps->points[i];
 pt_n = &gps->points[i + 1];

 /* Interpolate all values */
interp_v3_v3(&pt_n->x, &pt_a->x, &pt_b->x, 0.5f);
interpf(&pt_n->pressure, pt_a->pressure, pt_b->pressure);
// ...

Also note, the use of the interp functions from BLI_math instead of inlining the math here :)

AFAICT, there isn't really any reason why we need to make copies of everything first. It doesn't look like the ranges will overlap...

source/blender/makesdna/DNA_gpencil_types.h
134

Hmm... this isn't such a great name. What about "smooth_drawfac"?

source/blender/makesrna/intern/rna_gpencil.c
804

A better tooltip may be "Amount of smoothing to apply to newly created strokes, to reduce jitter/noise"

811

A better tooltip may be "Number of times to subdivide newly created strokes, for less jagged strokes"

This revision now requires changes to proceed.Mar 22 2016, 2:44 PM
Antonio Vazquez (antoniov) edited edge metadata.

Update after aligorith comments

This revision was automatically updated to reflect the committed changes.