Commit: 4c2561a87777d821dfb5f44463b4629a2206a9f2
Author: Antonioya
Date:   Thu Oct 25 16:50:42 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB4c2561a87777d821dfb5f44463b4629a2206a9f2

GP: Include option to render layers by view layer

This allows to make composition getting each grease pencil layer in a different 
render output.

===================================================================

M       release/scripts/startup/bl_ui/properties_data_gpencil.py
M       source/blender/draw/engines/gpencil/gpencil_draw_utils.c
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 29ba3c1ff83..a40ba463603 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -172,6 +172,7 @@ class 
DATA_PT_gpencil_layer_optionpanel(LayerDataButtonsPanel, Panel):
     def draw(self, context):
         layout = self.layout
         layout.use_property_split = True
+        scene = context.scene
 
         gpl = context.active_gpencil_layer
         layout.active = not gpl.lock
@@ -190,6 +191,9 @@ class 
DATA_PT_gpencil_layer_optionpanel(LayerDataButtonsPanel, Panel):
         col = layout.row(align=True)
         col.prop(gpl, "pass_index")
 
+        col = layout.row(align=True)
+        col.prop_search(gpl, "viewlayer_render", scene, "view_layers", 
text="View Layer")
+
         col = layout.row(align=True)
         col.prop(gpl, "lock_material")
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 641229446b9..c980e1791db 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1244,6 +1244,8 @@ void DRW_gpencil_populate_datablock(
 {
        GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
        const DRWContextState *draw_ctx = DRW_context_state_get();
+       const ViewLayer *view_layer = 
DEG_get_evaluated_view_layer(draw_ctx->depsgraph);
+
        bGPdata *gpd_eval = (bGPdata *)ob->data;
        bGPdata *gpd = (bGPdata *)DEG_get_original_id(&gpd_eval->id);
 
@@ -1278,6 +1280,14 @@ void DRW_gpencil_populate_datablock(
                /* don't draw layer if hidden */
                if (gpl->flag & GP_LAYER_HIDE)
                        continue;
+
+               /* filter view layer to gp layers in the same view layer (for 
compo) */
+               if ((stl->storage->is_render) && (gpl->viewlayername[0] != 
'\0')) {
+                       if (!STREQ(view_layer->name, gpl->viewlayername)) {
+                               continue;
+                       }
+               }
+
                if ((!time_remap) || (stl->storage->simplify_modif)) {
                        gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, 
GP_GETFRAME_USE_PREV);
                }
diff --git a/source/blender/makesdna/DNA_gpencil_types.h 
b/source/blender/makesdna/DNA_gpencil_types.h
index 54559ce89f7..2c59dd899a9 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -270,6 +270,7 @@ typedef struct bGPDlayer {
        short line_change;      /* Thickness adjustment */
        float tintcolor[4];     /* Color used to tint layer, alpha value is 
used as factor */
        float opacity;          /* Opacity of the layer */
+       char viewlayername[64]; /* Name of the layer used to filter render 
output */
 
        bGPDlayer_Runtime runtime;
 } bGPDlayer;
diff --git a/source/blender/makesrna/intern/rna_gpencil.c 
b/source/blender/makesrna/intern/rna_gpencil.c
index de31c884b6b..33100c21180 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1100,6 +1100,11 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Pass Index", "Index number for the 
\"Layer Index\" pass");
        RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, 
"rna_GPencil_update");
 
+       prop = RNA_def_property(srna, "viewlayer_render", PROP_STRING, 
PROP_NONE);
+       RNA_def_property_string_sdna(prop, NULL, "viewlayername");
+       RNA_def_property_ui_text(prop, "ViewLayer",
+               "Only include Layer in this View Layer render output (leave 
blank to include always)");
+
        /* Flags */
        prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_HIDE);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to