diff --git a/scripts/startup/bl_ui/properties_data_grease_pencil.py b/scripts/startup/bl_ui/properties_data_grease_pencil.py index 0f4bcd46462..d50ccbf29d8 100644 --- a/scripts/startup/bl_ui/properties_data_grease_pencil.py +++ b/scripts/startup/bl_ui/properties_data_grease_pencil.py @@ -69,6 +69,9 @@ class DATA_PT_grease_pencil_layers(DataButtonsPanel, Panel): col = layout.row(align=True) col.prop(layer, "opacity", text="Opacity", slider=True) + + col = layout.row(align=True) + col.prop(layer, "use_lights") classes = ( diff --git a/source/blender/blenkernel/BKE_grease_pencil.hh b/source/blender/blenkernel/BKE_grease_pencil.hh index 3a859354810..49ecf987e69 100644 --- a/source/blender/blenkernel/BKE_grease_pencil.hh +++ b/source/blender/blenkernel/BKE_grease_pencil.hh @@ -297,6 +297,7 @@ class Layer : public ::GreasePencilLayer { bool is_editable() const; bool is_empty() const; bool is_selected() const; + bool use_lights() const; bool use_onion_skinning() const; diff --git a/source/blender/blenkernel/intern/grease_pencil.cc b/source/blender/blenkernel/intern/grease_pencil.cc index 1ef2e95d950..c31280feae9 100644 --- a/source/blender/blenkernel/intern/grease_pencil.cc +++ b/source/blender/blenkernel/intern/grease_pencil.cc @@ -434,7 +434,7 @@ TreeNode::TreeNode() this->parent = nullptr; this->name = nullptr; - this->flag = 0; + this->flag = GP_LAYER_TREE_NODE_USE_LIGHTS; this->color[0] = this->color[1] = this->color[2] = 0; } @@ -605,6 +605,11 @@ bool Layer::is_selected() const return ((this->base.flag & GP_LAYER_TREE_NODE_SELECT) != 0); } +bool Layer::use_lights() const +{ + return (this->base.flag & GP_LAYER_TREE_NODE_USE_LIGHTS) != 0; +} + bool Layer::use_onion_skinning() const { return ((this->base.flag & GP_LAYER_TREE_NODE_USE_ONION_SKINNING) != 0); diff --git a/source/blender/draw/engines/gpencil/gpencil_layer.hh b/source/blender/draw/engines/gpencil/gpencil_layer.hh index 940be14a826..5af53f6c83e 100644 --- a/source/blender/draw/engines/gpencil/gpencil_layer.hh +++ b/source/blender/draw/engines/gpencil/gpencil_layer.hh @@ -47,6 +47,17 @@ class LayerModule { do_layer_blending = true; } + bool ob_shadeless = false; // TODO: ob.is_shadeless + if (ob_shadeless) { + gp_layer.use_lights = false; + } + else { + gp_layer.use_lights = layer.use_lights(); + if (!gp_layer.use_lights) { + do_layer_blending = true; + } + } + layers_buf_.append(gp_layer); } diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_shared.h b/source/blender/draw/engines/gpencil/gpencil_shader_shared.h index 50cbb813ac6..6ac1c4d9ebe 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_shared.h +++ b/source/blender/draw/engines/gpencil/gpencil_shader_shared.h @@ -161,6 +161,9 @@ struct gpLayer { float stroke_index_offset; /** Color to multiply to the final mixed color. */ float4 tint; + /** If the layer uses the scene lights. */ + bool1 use_lights; + bool1 _pad0[3]; }; BLI_STATIC_ASSERT_ALIGN(gpLayer, 16) diff --git a/source/blender/makesrna/intern/rna_grease_pencil.cc b/source/blender/makesrna/intern/rna_grease_pencil.cc index 3ae536416f0..951cb436498 100644 --- a/source/blender/makesrna/intern/rna_grease_pencil.cc +++ b/source/blender/makesrna/intern/rna_grease_pencil.cc @@ -214,6 +214,13 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna) prop = RNA_def_property(srna, "opacity", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, "GreasePencilLayer", "opacity"); RNA_def_property_ui_text(prop, "Opacity", "Layer Opacity"); + + /* Use Lights */ + prop = RNA_def_property(srna, "use_lights", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna( + prop, "GreasePencilLayerTreeNode", "flag", GP_LAYER_TREE_NODE_USE_LIGHTS); + RNA_def_property_ui_text( + prop, "Use Lights", "Enable the use of lights on stroke and fill materials"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update"); /* Onion Skinning. */