diff options
Diffstat (limited to 'source/blender/draw/engines/gpencil')
4 files changed, 25 insertions, 14 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c index 2b811f1d52e..d97bf9255d2 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c @@ -159,7 +159,7 @@ void gpencil_object_cache_sort(GPENCIL_PrivateData *pd) } } - /* Join both lists, adding infront. */ + /* Join both lists, adding in front. */ if (pd->tobjects_infront.first != NULL) { if (pd->tobjects.last != NULL) { pd->tobjects.last->next = pd->tobjects_infront.first; @@ -265,8 +265,10 @@ GPENCIL_tLayer *gpencil_layer_cache_add(GPENCIL_PrivateData *pd, GPENCIL_VERTEX_MODE(gpd) || pd->is_render; bool is_masked = (gpl->flag & GP_LAYER_USE_MASK) && !BLI_listbase_is_empty(&gpl->mask_layers); - float vert_col_opacity = (overide_vertcol) ? (is_vert_col_mode ? 1.0f : 0.0f) : - gpl->vertex_paint_opacity; + float vert_col_opacity = (overide_vertcol) ? + (is_vert_col_mode ? pd->vertex_paint_opacity : 0.0f) : + pd->is_render ? gpl->vertex_paint_opacity : + pd->vertex_paint_opacity; /* Negate thickness sign to tag that strokes are in screen space. * Convert to world units (by default, 1 meter = 2000 px). */ float thickness_scale = (is_screenspace) ? -1.0f : (gpd->pixfactor / GPENCIL_PIXEL_FACTOR); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 495de7ef10b..dded83bacf1 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -224,6 +224,7 @@ void GPENCIL_cache_init(void *ved) const bool is_fade_layer = ((!hide_overlay) && (!pd->is_render) && (draw_ctx->v3d->gp_flag & V3D_GP_FADE_NOACTIVE_LAYERS)); pd->fade_layer_opacity = (is_fade_layer) ? draw_ctx->v3d->overlay.gpencil_fade_layer : -1.0f; + pd->vertex_paint_opacity = draw_ctx->v3d->overlay.gpencil_vertex_paint_opacity; /* Fade GPencil Objects. */ const bool is_fade_object = ((!hide_overlay) && (!pd->is_render) && (draw_ctx->v3d->gp_flag & V3D_GP_FADE_OBJECTS) && @@ -383,7 +384,7 @@ static void gpencil_drawcall_flush(gpIterPopulateData *iter) } /* Group drawcalls that are consecutive and with the same type. Reduces GPU driver overhead. */ -static void gp_drawcall_add( +static void gpencil_drawcall_add( gpIterPopulateData *iter, struct GPUBatch *geom, bool instancing, int v_first, int v_count) { #if DISABLE_BATCHING @@ -413,7 +414,7 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl, bGPDstroke *gps, void *thunk); -static void gp_sbuffer_cache_populate(gpIterPopulateData *iter) +static void gpencil_sbuffer_cache_populate(gpIterPopulateData *iter) { iter->do_sbuffer_call = DRAW_NOW; /* In order to draw the sbuffer stroke correctly mixed with other strokes, @@ -450,7 +451,7 @@ static void gpencil_layer_cache_populate(bGPDlayer *gpl, gpencil_drawcall_flush(iter); if (iter->do_sbuffer_call) { - gp_sbuffer_cache_populate(iter); + gpencil_sbuffer_cache_populate(iter); } else { iter->do_sbuffer_call = !pd->do_fast_drawing && (gpd == pd->sbuffer_gpd) && @@ -492,8 +493,10 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl, (!iter->pd->simplify_fill) && ((gps->flag & GP_STROKE_NOFILL) == 0); bool only_lines = gpl && gpf && gpl->actframe != gpf && iter->pd->use_multiedit_lines_only; + bool hide_onion = gpl && gpf && gpf->runtime.onion_id != 0 && + ((gp_style->flag & GP_MATERIAL_HIDE_ONIONSKIN) != 0); - if (hide_material || (!show_stroke && !show_fill) || only_lines) { + if (hide_material || (!show_stroke && !show_fill) || only_lines || hide_onion) { return; } @@ -537,7 +540,7 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl, DRW_cache_gpencil_fills_get(iter->ob, iter->pd->cfra); int vfirst = gps->runtime.fill_start * 3; int vcount = gps->tot_triangles * 3; - gp_drawcall_add(iter, geom, false, vfirst, vcount); + gpencil_drawcall_add(iter, geom, false, vfirst, vcount); } if (show_stroke) { @@ -547,13 +550,13 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl, int vfirst = gps->runtime.stroke_start - 1; /* Include "potential" cyclic vertex and start adj vertex (see shader). */ int vcount = gps->totpoints + 1 + 1; - gp_drawcall_add(iter, geom, true, vfirst, vcount); + gpencil_drawcall_add(iter, geom, true, vfirst, vcount); } iter->stroke_index_last = gps->runtime.stroke_start + gps->totpoints + 1; } -static void gp_sbuffer_cache_populate_fast(GPENCIL_Data *vedata, gpIterPopulateData *iter) +static void gpencil_sbuffer_cache_populate_fast(GPENCIL_Data *vedata, gpIterPopulateData *iter) { bGPdata *gpd = (bGPdata *)iter->ob->data; if (gpd != iter->pd->sbuffer_gpd) { @@ -630,13 +633,13 @@ void GPENCIL_cache_populate(void *ved, Object *ob) gpencil_drawcall_flush(&iter); if (iter.do_sbuffer_call) { - gp_sbuffer_cache_populate(&iter); + gpencil_sbuffer_cache_populate(&iter); } gpencil_vfx_cache_populate(vedata, ob, iter.tgp_ob); if (pd->do_fast_drawing) { - gp_sbuffer_cache_populate_fast(vedata, &iter); + gpencil_sbuffer_cache_populate_fast(vedata, &iter); } } diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index cedd75af813..7baca28dca3 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -363,6 +363,8 @@ typedef struct GPENCIL_PrivateData { float xray_alpha; /* Mask invert uniform. */ int mask_invert; + /* Vertex Paint opacity. */ + float vertex_paint_opacity; } GPENCIL_PrivateData; /* geometry batch cache functions */ diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c index 7ce7a726bb7..cf6e78f4702 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c @@ -262,6 +262,8 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat mul_v3_m4v3(ob_center, persmat, ob->obmat[3]); mul_v3_fl(ob_center, 1.0f / w); + const bool use_antialiasing = ((fx->flag & FX_PIXEL_FILTER_NEAREST) == 0); + /* Convert to uvs. */ mul_v2_fl(ob_center, 0.5f); add_v2_fl(ob_center, 0.5f); @@ -285,7 +287,8 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat DRW_shgroup_uniform_vec2_copy(grp, "targetPixelSize", pixsize_uniform); DRW_shgroup_uniform_vec2_copy(grp, "targetPixelOffset", ob_center); DRW_shgroup_uniform_vec2_copy(grp, "accumOffset", (float[2]){pixel_size[0], 0.0f}); - DRW_shgroup_uniform_int_copy(grp, "sampCount", (pixel_size[0] / vp_size_inv[0] > 3.0) ? 2 : 1); + int samp_count = (pixel_size[0] / vp_size_inv[0] > 3.0) ? 2 : 1; + DRW_shgroup_uniform_int_copy(grp, "sampCount", use_antialiasing ? samp_count : 0); DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } @@ -294,7 +297,8 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat grp = gpencil_vfx_pass_create("Fx Pixelize Y", state, iter, sh); DRW_shgroup_uniform_vec2_copy(grp, "targetPixelSize", pixsize_uniform); DRW_shgroup_uniform_vec2_copy(grp, "accumOffset", (float[2]){0.0f, pixel_size[1]}); - DRW_shgroup_uniform_int_copy(grp, "sampCount", (pixel_size[1] / vp_size_inv[1] > 3.0) ? 2 : 1); + int samp_count = (pixel_size[1] / vp_size_inv[1] > 3.0) ? 2 : 1; + DRW_shgroup_uniform_int_copy(grp, "sampCount", use_antialiasing ? samp_count : 0); DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } } |