[Bf-blender-cvs] [a8bcfe4c31f] greasepencil-object: WIP: Support Blend layer
Antonioya
noreply at git.blender.org
Fri Nov 23 16:54:48 CET 2018
Commit: a8bcfe4c31f4facf82a8319309b072c118846f0b
Author: Antonioya
Date: Fri Nov 23 16:53:41 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBa8bcfe4c31f4facf82a8319309b072c118846f0b
WIP: Support Blend layer
This new option for Layers allow to define the blend mode between layers to create effects and help with the painting of the frames.
Note: If use substract to open holes, you can get the transparent problem we already know and that it's pending to solve using OIT.
===================================================================
M release/scripts/startup/bl_ui/properties_data_gpencil.py
M release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M release/scripts/startup/bl_ui/space_topbar.py
M source/blender/draw/CMakeLists.txt
M source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
A source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
M source/blender/makesdna/DNA_gpencil_types.h
M source/blender/makesrna/intern/rna_gpencil.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index 949a48ed7f1..3dc32fa7f81 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -161,6 +161,8 @@ class DATA_PT_gpencil_datapanel(Panel):
row = layout.row(align=True)
if gpl:
row.prop(gpl, "opacity", text="Opacity", slider=True)
+ row = layout.row(align=True)
+ row.prop(gpl, "blend_mode", text="Blend")
class DATA_PT_gpencil_layer_optionpanel(LayerDataButtonsPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 296e05a709d..14f59d0b369 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -766,7 +766,6 @@ class AnnotationDataPanel:
layout.prop(tool_settings, "annotation_thickness", text="Thickness")
if gpl:
- # layout.prop(gpl, "opacity", text="Opacity", slider=True)
# Full-Row - Frame Locking (and Delete Frame)
row = layout.row(align=True)
row.active = not gpl.lock
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 8b9c47839e9..76e5f00dd56 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -542,6 +542,8 @@ class TOPBAR_PT_gpencil_layers(Panel):
row = layout.row(align=True)
if gpl:
row.prop(gpl, "opacity", text="Opacity", slider=True)
+ row = layout.row(align=True)
+ row.prop(gpl, "blend_mode", text="Blend")
class TOPBAR_MT_editor_menus(Menu):
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 2097fb66c8b..0c0afdbe328 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -326,6 +326,7 @@ data_to_c_simple(engines/gpencil/shaders/gpencil_stroke_geom.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_stroke_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_zdepth_mix_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_simple_mix_frag.glsl SRC)
+data_to_c_simple(engines/gpencil/shaders/gpencil_blend_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_point_vert.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_point_geom.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_point_frag.glsl SRC)
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 15ac3f37add..91553681ae2 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -83,8 +83,12 @@ tGPencilObjectCache *gpencil_object_cache_add(
cache_elem->pixfactor = cache_elem->gpd->pixfactor;
cache_elem->shader_fx = ob_orig->shader_fx;
- cache_elem->init_grp = NULL;
- cache_elem->end_grp = NULL;
+ /* shgrp array */
+ cache_elem->tot_layers = 0;
+ int totgpl = BLI_listbase_count(&cache_elem->gpd->layers);
+ if (totgpl > 0) {
+ cache_elem->shgrp_array = MEM_callocN(sizeof(tGPencilObjectCache_shgrp) * totgpl, __func__);
+ }
/* calculate zdepth from point of view */
float zdepth = 0.0;
@@ -120,7 +124,7 @@ tGPencilObjectCache *gpencil_object_cache_add(
/* add a shading group to the cache to create later */
GpencilBatchGroup *gpencil_group_cache_add(
- GpencilBatchGroup *cache_array,
+ GpencilBatchGroup *cache_array, bGPdata *gpd,
bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps,
const short type, const bool onion,
const int vertex_idx,
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index c8b70953f87..ad54f0cc113 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -554,6 +554,8 @@ static void gpencil_add_fill_vertexdata(
float opacity, const float tintcolor[4], const bool onion, const bool custonion)
{
MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
+ bGPdata *gpd = (bGPdata *)ob->data;
+
if (gps->totpoints >= 3) {
float tfill[4];
/* set color using material, tint color and opacity */
@@ -581,7 +583,8 @@ static void gpencil_add_fill_vertexdata(
/* add to list of groups */
if (old_len < cache->b_fill.vbo_len) {
cache->grp_cache = gpencil_group_cache_add(
- cache->grp_cache, gpl, gpf, gps, eGpencilBatchGroupType_Fill, onion,
+ cache->grp_cache, gpd, gpl, gpf, gps,
+ eGpencilBatchGroupType_Fill, onion,
cache->b_fill.vbo_len,
&cache->grp_size, &cache->grp_used);
}
@@ -601,6 +604,7 @@ static void gpencil_add_stroke_vertexdata(
float ink[4];
short sthickness;
MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
+ bGPdata *gpd = (bGPdata *)ob->data;
/* set color using base color, tint color and opacity */
if (cache->is_dirty) {
@@ -637,7 +641,8 @@ static void gpencil_add_stroke_vertexdata(
/* add to list of groups */
if (old_len < cache->b_stroke.vbo_len) {
cache->grp_cache = gpencil_group_cache_add(
- cache->grp_cache, gpl, gpf, gps, eGpencilBatchGroupType_Stroke, onion,
+ cache->grp_cache, gpd, gpl, gpf, gps,
+ eGpencilBatchGroupType_Stroke, onion,
cache->b_stroke.vbo_len,
&cache->grp_size, &cache->grp_used);
}
@@ -650,7 +655,7 @@ static void gpencil_add_stroke_vertexdata(
/* add to list of groups */
if (old_len < cache->b_point.vbo_len) {
cache->grp_cache = gpencil_group_cache_add(
- cache->grp_cache, gpl, gpf, gps, eGpencilBatchGroupType_Point, onion,
+ cache->grp_cache, gpd, gpl, gpf, gps, eGpencilBatchGroupType_Point, onion,
cache->b_point.vbo_len,
&cache->grp_size, &cache->grp_used);
}
@@ -687,7 +692,8 @@ static void gpencil_add_editpoints_vertexdata(
/* add to list of groups */
cache->grp_cache = gpencil_group_cache_add(
- cache->grp_cache, gpl, gpf, gps, eGpencilBatchGroupType_Edlin, false,
+ cache->grp_cache, gpd, gpl, gpf, gps,
+ eGpencilBatchGroupType_Edlin, false,
cache->b_edlin.vbo_len,
&cache->grp_size, &cache->grp_used);
}
@@ -699,7 +705,8 @@ static void gpencil_add_editpoints_vertexdata(
/* add to list of groups */
cache->grp_cache = gpencil_group_cache_add(
- cache->grp_cache, gpl, gpf, gps, eGpencilBatchGroupType_Edit, false,
+ cache->grp_cache,gpd, gpl, gpf, gps,
+ eGpencilBatchGroupType_Edit, false,
cache->b_edit.vbo_len,
&cache->grp_size, &cache->grp_used);
}
@@ -1253,12 +1260,21 @@ static void DRW_gpencil_create_batches(GpencilBatchCache *cache)
/* create all shading groups */
static void DRW_gpencil_shgroups_create(
GPENCIL_e_data *e_data, void *vedata,
- Object *ob, bGPdata *gpd,
+ Object *ob,
GpencilBatchCache *cache, tGPencilObjectCache *cache_ob)
{
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
+ bGPdata *gpd = (bGPdata *)ob->data;
+
+ GpencilBatchGroup *elm = NULL;
DRWShadingGroup *shgrp = NULL;
+ tGPencilObjectCache_shgrp *array_elm = NULL;
+
+ bGPDlayer *gpl = NULL;
+ bGPDlayer *gpl_prev = NULL;
+ int idx = 0;
+ bool tag_first = false;
int start_stroke = 0;
int start_point = 0;
@@ -1266,12 +1282,27 @@ static void DRW_gpencil_shgroups_create(
int start_edit = 0;
int start_edlin = 0;
- cache_ob->init_grp = NULL;
- cache_ob->end_grp = NULL;
-
for (int i = 0; i < cache->grp_used; i++) {
- GpencilBatchGroup *elm = &cache->grp_cache[i];
- bGPDlayer *gpl = elm->gpl;
+ elm = &cache->grp_cache[i];
+ array_elm = &cache_ob->shgrp_array[idx];
+ /* save last group when change */
+ if (gpl_prev == NULL) {
+ gpl_prev = elm->gpl;
+ tag_first = true;
+ }
+ else {
+ if (elm->gpl != gpl_prev)
+ {
+ /* first layer is always blend Normal */
+ array_elm->mode = idx == 0 ? eGplBlendMode_Normal: gpl->blend_mode;
+ array_elm->end_shgrp = shgrp;
+ gpl_prev = elm->gpl;
+ tag_first = true;
+ idx++;
+ }
+ }
+
+ gpl = elm->gpl;
bGPDframe *gpf = elm->gpf;
bGPDstroke *gps = elm->gps;
MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
@@ -1365,14 +1396,20 @@ static void DRW_gpencil_shgroups_create(
}
}
/* save first group */
- if ((shgrp != NULL) && (cache_ob->init_grp == NULL)) {
- cache_ob->init_grp = shgrp;
+ if ((shgrp != NULL) && (tag_first)) {
+ array_elm = &cache_ob->shgrp_array[idx];
+ array_elm->mode = idx == 0 ? eGplBlendMode_Normal: gpl->blend_mode;
+ array_elm->init_shgrp = shgrp;
+ cache_ob->tot_layers++;
+
+ tag_first = false;
}
}
/* save last group */
if (shgrp != NULL) {
- cache_ob->end_grp = shgrp;
+ array_elm->mode = idx == 0 ? eGplBlendMode_Normal : gpl->blend_mode;
+ array_elm->end_shgrp = shgrp;
}
}
/* populate a datablock for multiedit (no onions, no modifiers) */
@@ -1425,7 +1462,7 @@ void DRW_gpencil_populate_multiedit(
/* create batchs and shading groups */
DRW_gpencil_create_batches(cache);
- DRW_gpencil_shgroups_create(e_data, vedata, ob, gpd, cache, cache_ob);
+ DRW_gpencil_shgroups_create(e_data, vedata, ob, cache, cache_ob);
cache->is_dirty = false;
}
@@ -1465,7 +1502,7 @@ void DRW_gpencil_populate_datablock(
/* if object is duplicate, only create shading groups */
if (cache_ob->is_dup_ob) {
- DRW_gpencil_shgroups_create(e_data, vedata, ob, gpd, cache, cache_ob);
+ DRW_gpencil_shgroups_create(e_data, vedata, ob, cache, cache_ob);
return;
}
@@ -1560,7 +1597,7 @@ void DRW_gpencil_populate_datablock(
/* create batchs and shading groups *
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list