[Bf-blender-cvs] [ca3cd8f9161] greasepencil-object: New Shader FX implementation

Antonio Vazquez noreply at git.blender.org
Fri Jul 6 08:47:22 CEST 2018


Commit: ca3cd8f91612f014328df811fa96e4f650e4d34d
Author: Antonio Vazquez
Date:   Fri Jul 6 08:46:00 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rBca3cd8f91612f014328df811fa96e4f650e4d34d

New Shader FX implementation

This is the new implementation of the old VFX modifiers.

- All the BKE functions have been separated in new module and a new listbase was added to Object struct. Now the modifiers and the new shader FX are totally separated.

- Added a new section in properties panel for FX. ToDo: New Icon.

- Drawing methods improved aand new Rim and Colorize FX created.

Some functions and code (glsl and DRW_*) could be shared by other modules in the future, but as today only grease pencil is using it and the logic depend of the drawing engine, we decided to keep inside the GPencil drawing engine.

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

M	build_files/cmake/macros.cmake
M	release/scripts/startup/bl_ui/__init__.py
M	release/scripts/startup/bl_ui/properties_data_modifier.py
A	release/scripts/startup/bl_ui/properties_data_shaderfx.py
M	source/blender/CMakeLists.txt
M	source/blender/blenkernel/BKE_object.h
A	source/blender/blenkernel/BKE_shader_fx.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/object.c
A	source/blender/blenkernel/intern/shader_fx.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/draw/CMakeLists.txt
M	source/blender/draw/engines/gpencil/gpencil_engine.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h
M	source/blender/draw/engines/gpencil/gpencil_render.c
A	source/blender/draw/engines/gpencil/gpencil_shader_fx.c
A	source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_blur_frag.glsl
A	source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_colorize_frag.glsl
A	source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_flip_frag.glsl
A	source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_light_frag.glsl
A	source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_pixel_frag.glsl
A	source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_rim_prepare_frag.glsl
A	source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_rim_resolve_frag.glsl
A	source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_swirl_frag.glsl
A	source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_wave_frag.glsl
M	source/blender/editors/include/ED_object.h
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/object/CMakeLists.txt
M	source/blender/editors/object/object_add.c
M	source/blender/editors/object/object_intern.h
M	source/blender/editors/object/object_ops.c
A	source/blender/editors/object/object_shader_fx.c
M	source/blender/editors/space_buttons/buttons_context.c
M	source/blender/editors/space_buttons/space_buttons.c
M	source/blender/makesdna/DNA_object_types.h
A	source/blender/makesdna/DNA_shader_fx_types.h
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/RNA_enum_types.h
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_object.c
A	source/blender/makesrna/intern/rna_shader_fx.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_ui_api.c
A	source/blender/shader_fx/CMakeLists.txt
A	source/blender/shader_fx/FX_shader_types.h
A	source/blender/shader_fx/intern/FX_shader_blur.c
A	source/blender/shader_fx/intern/FX_shader_colorize.c
A	source/blender/shader_fx/intern/FX_shader_flip.c
A	source/blender/shader_fx/intern/FX_shader_light.c
A	source/blender/shader_fx/intern/FX_shader_pixel.c
A	source/blender/shader_fx/intern/FX_shader_rim.c
A	source/blender/shader_fx/intern/FX_shader_swirl.c
A	source/blender/shader_fx/intern/FX_shader_util.c
A	source/blender/shader_fx/intern/FX_shader_util.h
A	source/blender/shader_fx/intern/FX_shader_wave.c
M	source/creator/creator.c

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

diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 0798a9b147e..3c2c1137c03 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -627,6 +627,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
 		bf_ikplugin
 		bf_modifiers
 		bf_gpencil_modifiers
+		bf_shader_fx
 		bf_alembic
 		bf_bmesh
 		bf_gpu
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index 1400eb59019..4abc336cd39 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -40,6 +40,7 @@ _modules = [
     "properties_data_mesh",
     "properties_data_metaball",
     "properties_data_modifier",
+    "properties_data_shaderfx",
     "properties_data_lightprobe",
     "properties_data_speaker",
     "properties_data_workspace",
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 5d95db475c0..6b13c3ce779 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -28,7 +28,6 @@ class ModifierButtonsPanel:
     bl_context = "modifier"
     bl_options = {'HIDE_HEADER'}
 
-
 class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
     bl_label = "Modifiers"
 
@@ -1980,6 +1979,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         row.prop(md, "pass_index", text="Pass")
         row.prop(md, "invert_pass", text="", icon="ARROW_LEFTRIGHT")
 
+
 classes = (
     DATA_PT_modifiers,
     DATA_PT_gpencil_modifiers,
diff --git a/release/scripts/startup/bl_ui/properties_data_shaderfx.py b/release/scripts/startup/bl_ui/properties_data_shaderfx.py
new file mode 100644
index 00000000000..5010f56d234
--- /dev/null
+++ b/release/scripts/startup/bl_ui/properties_data_shaderfx.py
@@ -0,0 +1,134 @@
+# ##### 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>
+import bpy
+from bpy.types import Panel
+from bpy.app.translations import pgettext_iface as iface_
+
+
+class ShaderFxButtonsPanel:
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "shaderfx"
+    bl_options = {'HIDE_HEADER'}
+
+class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
+    bl_label = "Effects"
+
+    @classmethod
+    def poll(cls, context):
+        return True
+        ob = context.object
+        return ob and ob.type == 'GPENCIL'
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+
+        ob = context.object
+
+        layout.operator_menu_enum("object.shaderfx_add", "type")
+
+        for fx in ob.shader_effects:
+            box = layout.template_shaderfx(fx)
+            if box:
+                # match enum type to our functions, avoids a lookup table.
+                getattr(self, fx.type)(box, fx)
+
+    # the mt.type enum is (ab)used for a lookup on function names
+    # ...to avoid lengthy if statements
+    # so each type must have a function here.
+
+    def FX_BLUR(self, layout, fx):
+
+        layout.prop(fx, "factor", text="Factor")
+        layout.prop(fx, "samples", text="Samples")
+
+        layout.separator()
+        layout.prop(fx, "use_dof_mode")
+        if fx.use_dof_mode:
+            layout.prop(fx, "coc")
+
+    def FX_COLORIZE(self, layout, fx):
+        layout.prop(fx, "mode", text="Mode")
+
+        if fx.mode == 'BITONE':
+            layout.prop(fx, "low_color", text="Low Color")
+        if fx.mode == 'CUSTOM':
+            layout.prop(fx, "low_color", text="Color")
+
+        if fx.mode == 'BITONE':
+            layout.prop(fx, "high_color", text="High Color")
+
+        if fx.mode in {'BITONE', 'CUSTOM', 'TRANSPARENT'}:
+            layout.prop(fx, "factor")
+
+    def FX_WAVE(self, layout,fx):
+        layout.prop(fx, "orientation", expand=True)
+
+        layout.separator()
+        layout.prop(fx, "amplitude")
+        layout.prop(fx, "period")
+        layout.prop(fx, "phase")
+
+    def FX_PIXEL(self, layout, fx):
+        layout.prop(fx, "size", text="Size")
+
+        layout.prop(fx, "use_lines", text="Display Lines")
+
+        col = layout.column()
+        col.enabled = fx.use_lines
+        col.prop(fx, "color")
+
+    def FX_RIM(self, layout, fx):
+        layout.prop(fx, "offset", text="Offset")
+
+        layout.prop(fx, "rim_color")
+        layout.prop(fx, "mask_color")
+        layout.prop(fx, "mode")
+        layout.prop(fx, "blur")
+        layout.prop(fx, "samples")
+
+    def FX_SWIRL(self, layout, fx):
+        layout.prop(fx, "object", text="Object")
+
+        layout.prop(fx, "radius")
+        layout.prop(fx, "angle")
+
+        layout.prop(fx, "transparent")
+
+    def FX_FLIP(self, layout, fx):
+        layout.prop(fx, "flip_horizontal")
+        layout.prop(fx, "flip_vertical")
+
+    def FX_LIGHT(self, layout, fx):
+        layout.prop(fx, "object", text="Object")
+
+        layout.prop(fx, "energy")
+        layout.prop(fx, "ambient")
+
+
+classes = (
+    DATA_PT_shader_fx,
+)
+
+if __name__ == "__main__":  # only for live edit.
+    from bpy.utils import register_class
+    for cls in classes:
+        register_class(cls)
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 57eecd1c71e..2c9b1efe2f4 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -46,6 +46,7 @@ set(SRC_DNA_INC
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_genfile.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_modifier_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_types.h
+	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_shader_fx_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpu_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_group_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_image_types.h
@@ -114,6 +115,7 @@ add_subdirectory(imbuf)
 add_subdirectory(nodes)
 add_subdirectory(modifiers)
 add_subdirectory(gpencil_modifiers)
+add_subdirectory(shader_fx)
 add_subdirectory(makesdna)
 add_subdirectory(makesrna)
 
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index f27ca51346d..4fe6fb9dbdd 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -39,6 +39,7 @@ struct Base;
 struct Depsgraph;
 struct GpencilModifierData;
 struct Scene;
+struct ShaderFxData;
 struct ViewLayer;
 struct ID;
 struct Object;
@@ -75,10 +76,13 @@ void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData *
 void BKE_object_modifier_gpencil_hook_reset(struct Object *ob, struct HookGpencilModifierData *hmd);
 bool BKE_object_modifier_gpencil_use_time(struct Object *ob, struct GpencilModifierData *md);
 
+bool BKE_object_shaderfx_use_time(struct Object *ob, struct ShaderFxData *md);
+
 bool BKE_object_support_modifier_type_check(const struct Object *ob, int modifier_type);
 
 void BKE_object_link_modifiers(struct Scene *scene, struct Object *ob_dst, const struct Object *ob_src);
 void BKE_object_free_modifiers(struct Object *ob, const int flag);
+void BKE_object_free_shaderfx(struct Object *ob, const int flag);
 
 void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob);
 void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target);
diff --git a/source/blender/blenkernel/BKE_shader_fx.h b/source/blender/blenkernel/BKE_shader_fx.h
new file mode 100644
index 00000000000..11c5983106a
--- /dev/null
+++ b/source/blender/blenkernel/BKE_shader_fx.h
@@ -0,0 +1,180 @@
+/*
+ * ***** 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.
+ *
+ * The Original Code is: all of this file.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef __BKE_SHADER_FX_H__
+#define __BKE_SHADER_FX_H__
+
+/** \file BKE_shader_fx.h
+ *  \ingroup bke
+ */
+
+#include "DNA_shader_fx_types.h"     /* needed for all enum typdefs */
+#include "BLI_compiler_attrs.h"
+#include "BKE_customdata.h"
+
+struct ID;
+struct Depsgraph;
+struct DerivedMesh;
+struct Mesh;
+struct Object;
+struct Scene;
+struct ViewLayer;
+struct ListBase;
+struct bArmature;
+struct Main;
+struct ShaderFxData;
+struct DepsNodeHandle;
+struct bGPDlayer;
+struct bGPDframe;
+struct bGPDstroke;
+struct ModifierUpdateDepsgraphContext;
+
+#define SHADER_FX_ACTIVE(_fx, _is_render) (((_fx->mode & eShaderFxMode_Realtime) && (_is_render == false)) || \
+												  ((_fx->mode & eShaderFxMode_Render) && (_is_render == true))) 
+#define SHADER_FX_EDIT(_fx, _is_edit) (((_fx->mode & eShaderFxMode_Editmode) == 0) && (_is_edit))
+
+typedef enum {
+	/* Should not be used, only for None type */
+	eShaderFxType_NoneType,
+
+	/* grease pencil effects */
+	eShaderFxType_GpencilType,
+}  ShaderFxTypeType;
+
+typed

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list