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:
authorAntonioya <blendergit@gmail.com>2019-02-25 19:41:02 +0300
committerAntonioya <blendergit@gmail.com>2019-02-25 19:46:15 +0300
commit5d8a8a684253da03bf20182be443c2bd03798a49 (patch)
treea823841a83718076f74c50191c4ac5e0ed1260cc /source/blender
parentcfc2fa33bfcd1517731a266b9169b3d6a5b80ced (diff)
GP: Add support for Wireframe mode
When enable Wireframe mode in the shading type, all strokes are displayed as simple 1 pixel lines. The color of the line is equal to the stroke color or the fill color if the fill is enabled and the stroke is disabled or has invisible alpha value. In wireframe mode, all FX are disabled because sometimes the effects can make the lines invisible. The modifiers are not disabled. Still pending to decide if we must add support for Random colors, but not sure if this is useful in 2D.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_utils.c32
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c15
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h3
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_shader_fx.c4
4 files changed, 45 insertions, 9 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index c2932b34b65..d505095a393 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -598,7 +598,7 @@ static void gpencil_add_stroke_vertexdata(
GpencilBatchCache *cache,
Object *ob, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps,
const float opacity, const float tintcolor[4], const bool onion,
- const bool custonion)
+ const bool custonion, const bool use_wiremode)
{
float tcolor[4];
float ink[4];
@@ -616,6 +616,15 @@ static void gpencil_add_stroke_vertexdata(
else {
interp_v3_v3v3(tcolor, gps->runtime.tmp_stroke_rgba, tintcolor, tintcolor[3]);
tcolor[3] = gps->runtime.tmp_stroke_rgba[3] * opacity;
+
+ if ((use_wiremode) &&
+ ((gps->runtime.tmp_stroke_rgba[3] < GPENCIL_ALPHA_OPACITY_THRESH) ||
+ (((gp_style->flag & GP_STYLE_STROKE_SHOW) == 0))) &&
+ (gps->runtime.tmp_fill_rgba[3] >= GPENCIL_ALPHA_OPACITY_THRESH))
+ {
+ interp_v3_v3v3(tcolor, gps->runtime.tmp_fill_rgba, tintcolor, tintcolor[3]);
+ tcolor[3] = gps->runtime.tmp_fill_rgba[3] * opacity;
+ }
}
copy_v4_v4(ink, tcolor);
}
@@ -629,8 +638,14 @@ static void gpencil_add_stroke_vertexdata(
}
}
- sthickness = gps->thickness + gpl->line_change;
- CLAMP_MIN(sthickness, 1);
+ /* if wireframe mode, set thickeness to 1 */
+ if (!use_wiremode) {
+ sthickness = gps->thickness + gpl->line_change;
+ CLAMP_MIN(sthickness, 1);
+ }
+ else {
+ sthickness = 1;
+ }
if ((gps->totpoints > 1) && (gp_style->mode == GP_STYLE_MODE_LINE)) {
/* create vertex data */
@@ -812,6 +827,7 @@ static void gpencil_draw_strokes(
/* fill */
if ((gp_style->flag & GP_STYLE_FILL_SHOW) &&
(!stl->storage->simplify_fill) &&
+ (stl->storage->shading_type != OB_WIRE) &&
((gps->flag & GP_STROKE_NOFILL) == 0))
{
gpencil_add_fill_vertexdata(
@@ -821,13 +837,15 @@ static void gpencil_draw_strokes(
/* stroke */
/* No fill strokes, must show stroke always */
if (((gp_style->flag & GP_STYLE_STROKE_SHOW) ||
- (gps->flag & GP_STROKE_NOFILL)) &&
+ (gps->flag & GP_STROKE_NOFILL) ||
+ (stl->storage->shading_type == OB_WIRE)) &&
((gp_style->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) ||
(gpl->blend_mode == eGplBlendMode_Normal)))
{
gpencil_add_stroke_vertexdata(
cache, ob, gpl, derived_gpf, gps,
- opacity, tintcolor, false, custonion);
+ opacity, tintcolor, false, custonion,
+ (stl->storage->shading_type == OB_WIRE));
}
}
}
@@ -906,7 +924,9 @@ static void gpencil_draw_onion_strokes(
/* stroke */
gpencil_add_stroke_vertexdata(
- cache, ob, gpl, gpf, gps, opacity, tintcolor, true, custonion);
+ cache, ob, gpl, gpf, gps, opacity, tintcolor,
+ true, custonion,
+ (stl->storage->shading_type == OB_WIRE));
stl->storage->shgroup_id++;
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 69b495cfc6d..d2a7ca5a87b 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -385,6 +385,14 @@ void GPENCIL_cache_init(void *vedata)
stl->storage->simplify_fx = GP_SIMPLIFY_FX(scene, stl->storage->is_playing);
stl->storage->simplify_blend = GP_SIMPLIFY_BLEND(scene, stl->storage->is_playing);
+ /* save shading type */
+ if (v3d) {
+ stl->storage->shading_type = v3d->shading.type;
+ }
+ else {
+ stl->storage->shading_type = OB_SOLID;
+ }
+
/* save pixsize */
stl->storage->pixsize = DRW_viewport_pixelsize_get();
if ((!DRW_state_is_opengl_render()) && (stl->storage->is_render)) {
@@ -514,7 +522,9 @@ void GPENCIL_cache_init(void *vedata)
DRW_shgroup_uniform_int(mix_shgrp, "tonemapping", &stl->storage->tonemapping, 1);
/* create effects passes */
- if (!stl->storage->simplify_fx) {
+ if ((!stl->storage->simplify_fx) &&
+ (stl->storage->shading_type != OB_WIRE))
+ {
GPENCIL_create_fx_passes(psl);
}
}
@@ -542,7 +552,8 @@ static void gpencil_add_draw_data(void *vedata, Object *ob)
/* FX passses */
cache_ob->has_fx = false;
if ((!stl->storage->simplify_fx) &&
- (BKE_shaderfx_has_gpencil(ob)))
+ (stl->storage->shading_type != OB_WIRE) &&
+ (BKE_shaderfx_has_gpencil(ob)))
{
cache_ob->has_fx = true;
if ((!stl->storage->simplify_fx) && (!is_multiedit)) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index e1caef689ca..0e0dc3c5220 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -158,6 +158,9 @@ typedef struct GPENCIL_Storage {
float grid_matrix[4][4];
+ /* shading type */
+ char shading_type;
+
Object *camera; /* camera pointer for render mode */
} GPENCIL_Storage;
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index ad13ebb32f3..0cf5929db87 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -746,9 +746,11 @@ void DRW_gpencil_fx_prepare(
tGPencilObjectCache *cache)
{
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
+ const bool wiremode = (bool)(stl->storage->shading_type == OB_WIRE);
+
int ob_idx = cache->idx;
- if (cache->shader_fx.first == NULL) {
+ if ((wiremode) || (cache->shader_fx.first == NULL)) {
return;
}
/* loop FX */