[Bf-blender-cvs] [3e87d8a4315] master: Grease Pencil: Add LineArt modifier

YimingWu noreply at git.blender.org
Tue Mar 16 19:59:50 CET 2021


Commit: 3e87d8a4315d794efff659e40f0bb9e34e2aec8a
Author: YimingWu
Date:   Tue Mar 16 19:35:53 2021 +0100
Branches: master
https://developer.blender.org/rB3e87d8a4315d794efff659e40f0bb9e34e2aec8a

Grease Pencil: Add LineArt modifier

This adds the LineArt grease pencil modifier.

It takes objects or collections as input and generates various grease
pencil lines from these objects with the help of the active scene
camera. For example it can generate contour lines, intersection lines
and crease lines to name a few.

This is really useful as artists can then use 3D meshes to automatically
generate grease pencil lines for characters, enviroments or other
visualization purposes.

These lines can then be baked and edited as regular grease pencil lines.

Reviewed By: Sebastian Parborg, Antonio Vazquez, Matias Mendiola

Differential Revision: http://developer.blender.org/D8758

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

M	release/scripts/startup/bl_ui/__init__.py
A	release/scripts/startup/bl_ui/properties_collection.py
A	release/scripts/startup/bl_ui/properties_lineart.py
M	release/scripts/startup/bl_ui/properties_material.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/CMakeLists.txt
M	source/blender/blenkernel/BKE_collection.h
M	source/blender/blenkernel/BKE_global.h
M	source/blender/blenkernel/BKE_gpencil.h
M	source/blender/blenkernel/BKE_gpencil_modifier.h
M	source/blender/blenkernel/intern/collection.c
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/blenlib/BLI_math_base.h
M	source/blender/blenlib/intern/math_base_inline.c
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/editors/gpencil/CMakeLists.txt
A	source/blender/editors/gpencil/gpencil_add_lineart.c
M	source/blender/editors/include/ED_gpencil.h
M	source/blender/editors/mesh/editmesh_tools.c
M	source/blender/editors/mesh/mesh_intern.h
M	source/blender/editors/mesh/mesh_ops.c
M	source/blender/editors/object/object_add.c
M	source/blender/editors/object/object_ops.c
M	source/blender/editors/space_buttons/buttons_context.c
M	source/blender/editors/space_buttons/space_buttons.c
M	source/blender/gpencil_modifiers/CMakeLists.txt
A	source/blender/gpencil_modifiers/MOD_gpencil_lineart.h
M	source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
M	source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
A	source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
M	source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
A	source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
A	source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
A	source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
A	source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h
A	source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
A	source/blender/gpencil_modifiers/intern/lineart/lineart_util.c
M	source/blender/makesdna/DNA_collection_types.h
M	source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M	source/blender/makesdna/DNA_gpencil_modifier_types.h
M	source/blender/makesdna/DNA_gpencil_types.h
A	source/blender/makesdna/DNA_lineart_types.h
M	source/blender/makesdna/DNA_material_types.h
M	source/blender/makesdna/DNA_object_defaults.h
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesdna/intern/dna_defaults.c
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/rna_collection.c
M	source/blender/makesrna/intern/rna_gpencil_modifier.c
M	source/blender/makesrna/intern/rna_material.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/windowmanager/WM_api.h

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

diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index b3131e64df7..86c376bcb21 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -67,6 +67,7 @@ _modules = [
     "properties_scene",
     "properties_texture",
     "properties_world",
+    "properties_collection",
 
     # Generic Space Modules
     #
@@ -104,6 +105,8 @@ import bpy
 if bpy.app.build_options.freestyle:
     _modules.append("properties_freestyle")
 
+_modules.append("properties_lineart")
+
 __import__(name=__name__, fromlist=_modules)
 _namespace = globals()
 _modules_loaded = [_namespace[name] for name in _modules]
diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
new file mode 100644
index 00000000000..fa4c3cdb779
--- /dev/null
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -0,0 +1,98 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+from bpy.types import Panel
+
+
+class CollectionButtonsPanel:
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "collection"
+
+
+def lineart_make_line_type_entry(col, line_type, text_disp, expand, search_from):
+    col.prop(line_type, "use", text=text_disp)
+    if line_type.use and expand:
+        col.prop_search(line_type, "layer", search_from,
+                        "layers", icon='GREASEPENCIL')
+        col.prop_search(line_type, "material",  search_from,
+                        "materials", icon='SHADING_TEXTURE')
+
+
+class COLLECTION_PT_collection_flags(CollectionButtonsPanel, Panel):
+    bl_label = "Restrictions"
+
+    @classmethod
+    def poll(cls, context):
+        vl = context.view_layer
+        vlc = vl.active_layer_collection
+        return (vlc.name != 'Master Collection')
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+
+        collection = context.collection
+        vl = context.view_layer
+        vlc = vl.active_layer_collection
+
+        col = layout.column(align=True)
+        col.prop(collection, "hide_select", text="Selectable", toggle=False, invert_checkbox=True)
+        col.prop(collection, "hide_render", toggle=False)
+
+        col = layout.column(align=True)
+        col.prop(vlc, "holdout", toggle=False)
+        col.prop(vlc, "indirect_only", toggle=False)
+
+
+class COLLECTION_PT_lineart_collection(CollectionButtonsPanel, Panel):
+    bl_label = "Line Art"
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+        collection = context.collection
+
+        row = layout.row()
+        row.prop(collection, "lineart_usage")
+
+class COLLECTION_PT_instancing(CollectionButtonsPanel, Panel):
+    bl_label = "Instancing"
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+        collection = context.collection
+
+        row = layout.row()
+        row.prop(collection, "instance_offset")
+
+classes = (
+    COLLECTION_PT_collection_flags,
+    COLLECTION_PT_lineart_collection,
+    COLLECTION_PT_instancing,
+)
+
+if __name__ == "__main__":  # only for live edit.
+    from bpy.utils import register_class
+    for cls in classes:
+        register_class(cls)
diff --git a/release/scripts/startup/bl_ui/properties_lineart.py b/release/scripts/startup/bl_ui/properties_lineart.py
new file mode 100644
index 00000000000..7c4d6c7be0b
--- /dev/null
+++ b/release/scripts/startup/bl_ui/properties_lineart.py
@@ -0,0 +1,59 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+from bpy.types import Panel
+
+
+class LineartButtonsPanel:
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "object"
+
+
+class OBJECT_PT_lineart(LineartButtonsPanel, Panel):
+    bl_label = "Line Art"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        ob = context.object
+        return (ob.type in {'MESH', 'FONT', 'CURVE', 'SURFACE'})
+
+    def draw(self, context):
+        layout = self.layout
+        lineart = context.object.lineart
+
+        layout.use_property_split = True
+
+        layout.prop(lineart, 'usage')
+        layout.use_property_split = True
+
+        row = layout.row(heading="Override Crease")
+        row.prop(lineart, "use_crease_override", text="")
+        row.prop(lineart, "crease_threshold", slider=True, text="")
+
+
+classes = (
+    OBJECT_PT_lineart,
+)
+
+if __name__ == "__main__":  # only for live edit.
+    from bpy.utils import register_class
+    for cls in classes:
+        register_class(cls)
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 47ab98386f4..ebd91143239 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -274,6 +274,38 @@ class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel):
         col.prop(mat, "roughness")
 
 
+class MATERIAL_PT_lineart(MaterialButtonsPanel, Panel):
+    bl_label = "Line Art"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        mat = context.material
+        return mat and not mat.grease_pencil
+
+    def draw(self, context):
+        layout = self.layout
+
+        mat = context.material
+        lineart = mat.lineart
+
+        layout.prop(lineart, "use_transparency")
+
+        if lineart.use_transparency:
+
+            layout.label(text="Transparency Masks:")
+
+            row = layout.row(align=True)
+            row.prop(lineart, "transparency_mask_0", text="0", toggle=True)
+            row.prop(lineart, "transparency_mask_1", text="1", toggle=True)
+            row.prop(lineart, "transparency_mask_2", text="2", toggle=True)
+            row.prop(lineart, "transparency_mask_3", text="3", toggle=True)
+            row.prop(lineart, "transparency_mask_4", text="4", toggle=True)
+            row.prop(lineart, "transparency_mask_5", text="5", toggle=True)
+            row.prop(lineart, "transparency_mask_6", text="6", toggle=True)
+            row.prop(lineart, "transparency_mask_7", text="7", toggle=True)
+
+
 classes = (
     MATERIAL_MT_context_menu,
     MATERIAL_UL_matslots,
@@ -282,6 +314,7 @@ classes = (
     EEVEE_MATERIAL_PT_surface,
     EEVEE_MATERIAL_PT_volume,
     EEVEE_MATERIAL_PT_settings,
+    MATERIAL_PT_lineart,
     MATERIAL_PT_viewport,
     EEVEE_MATERIAL_PT_viewport_settings,
     MATERIAL_PT_custom_props,
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 2742b75a68b..6980181a725 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3829,11 +3829,10 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
             col.operator("mesh.mark_sharp")
             col.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
 
-            if render.use_freestyle:
-                col.separator()
+            col.separator()
 
-                col.operator("mesh.mark_freestyle_edge").clear = False
-                col.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
+            col.operator("mesh.mark_freestyle_edge").clear = False
+            col.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
 
             col.separator()
 
@@ -4028,11 +4027,10 @@ class VIEW3D_MT_edit_mesh_edges_data(Menu):
         props.use_verts = True
         props.clear = True
 
-        if render.use_freestyle:
-            layout.separator()
+        layout.separator()
 
-            layout.operator("mesh.mark_freestyle_edge").clear = False
-            layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
+        layout.operator("mesh.mark_freestyle_edge").clear = False
+        layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
 
 
 class VIEW3D_MT_edit_mesh_edges(Menu):
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index f875a990d0a..8d18cf0ae9a 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -56,6 +56,7 @@ set(SRC_DNA_INC
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_layer_types.h
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_light_types.h
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lightprobe_types.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/m

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list