[Bf-blender-cvs] [34c133a] master: Freestyle: an improved workflow of line style shading nodes.

Tamito Kajiyama noreply at git.blender.org
Tue Aug 12 03:17:54 CEST 2014


Commit: 34c133a488bdd78a1bd5027e1dcc8c60da86d25a
Author: Tamito Kajiyama
Date:   Sat Jul 19 18:52:32 2014 +0900
Branches: master
https://developer.blender.org/rB34c133a488bdd78a1bd5027e1dcc8c60da86d25a

Freestyle: an improved workflow of line style shading nodes.

Removed the previous changes for passing a line style through the Controller, and
revised the BlenderTextureShader to assign the shader node tree of a line style
(if specified) to strokes.  This way the assignment of shading nodes can be done
through both the Freestyle GUI and Python scripting.

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

M	release/scripts/freestyle/modules/parameter_editor.py
M	source/blender/freestyle/intern/application/Controller.cpp
M	source/blender/freestyle/intern/application/Controller.h
M	source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
M	source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
M	source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
M	source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
M	source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
M	source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
M	source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
M	source/blender/freestyle/intern/stroke/Stroke.cpp
M	source/blender/freestyle/intern/stroke/Stroke.h
M	source/blender/freestyle/intern/stroke/StrokeLayer.cpp
M	source/blender/freestyle/intern/stroke/StrokeLayer.h
M	source/blender/freestyle/intern/stroke/StrokeRep.cpp
M	source/blender/freestyle/intern/stroke/StrokeRep.h
M	source/blender/freestyle/intern/stroke/StyleModule.h

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

diff --git a/release/scripts/freestyle/modules/parameter_editor.py b/release/scripts/freestyle/modules/parameter_editor.py
index 995a917..161a16e 100644
--- a/release/scripts/freestyle/modules/parameter_editor.py
+++ b/release/scripts/freestyle/modules/parameter_editor.py
@@ -1078,8 +1078,7 @@ def process(layer_name, lineset_name):
     has_tex = False
     if scene.render.use_shading_nodes:
         if linestyle.use_nodes and linestyle.node_tree:
-            ### TODO ###
-            #shaders_list.append(BlenderTextureShader(linestyle.nodetree))
+            shaders_list.append(BlenderTextureShader(linestyle.node_tree))
             has_tex = True
     else:
         if linestyle.use_texture:
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index 4fd58ab..8f57bbe 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -892,10 +892,9 @@ void Controller::InsertStyleModule(unsigned index, const char *iFileName)
 	_Canvas->InsertStyleModule(index, sm);
 }
 
-void Controller::InsertStyleModule(unsigned index, const char *iName, struct Text *iText,
-                                   struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes)
+void Controller::InsertStyleModule(unsigned index, const char *iName, struct Text *iText)
 {
-	StyleModule *sm = new BlenderStyleModule(iName, _inter, iText, iLineStyle, iUseShadingNodes);
+	StyleModule *sm = new BlenderStyleModule(iText, iName, _inter);
 	_Canvas->InsertStyleModule(index, sm);
 }
 
diff --git a/source/blender/freestyle/intern/application/Controller.h b/source/blender/freestyle/intern/application/Controller.h
index c4f2596..a653f4a 100644
--- a/source/blender/freestyle/intern/application/Controller.h
+++ b/source/blender/freestyle/intern/application/Controller.h
@@ -89,8 +89,7 @@ public:
 	Render *RenderStrokes(Render *re, bool render);
 	void SwapStyleModules(unsigned i1, unsigned i2);
 	void InsertStyleModule(unsigned index, const char *iFileName);
-	void InsertStyleModule(unsigned index, const char *iName, struct Text *iText,
-                           struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes);
+	void InsertStyleModule(unsigned index, const char *iName, struct Text *iText);
 	void AddStyleModule(const char *iFileName);
 	void RemoveStyleModule(unsigned index);
 	void ReloadStyleModule(unsigned index, const char * iFileName);
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index a9ab69c..ec78a0f 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -146,7 +146,9 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(bContext *C, Render *re, int render
 
 BlenderStrokeRenderer::~BlenderStrokeRenderer()
 {
-	return; //XXX
+#if 0
+	return; // XXX
+#endif
 
 	// The freestyle_scene object is not released here.  Instead,
 	// the scene is released in free_all_freestyle_renders() in
@@ -217,7 +219,7 @@ unsigned int BlenderStrokeRenderer::get_stroke_mesh_id(void) const
 	return mesh_id;
 }
 
-Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, FreestyleLineStyle *linestyle)
+Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, bNodeTree *iNodeTree)
 {
 	Material *ma = BKE_material_add(bmain, "stroke_shader");
 	bNodeTree *ntree;
@@ -226,9 +228,9 @@ Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, Frees
 	PointerRNA fromptr, toptr;
 
 	cout << "linestyle " << linestyle << " nodetree " << linestyle->nodetree << " use_nodes " << linestyle->use_nodes << endl;
-	if (linestyle && linestyle->use_nodes && linestyle->nodetree) {
+	if (iNodeTree) {
 		// make a copy of linestyle->nodetree
-		ntree = ntreeCopyTree_ex(linestyle->nodetree, bmain, true);
+		ntree = ntreeCopyTree_ex(iNodeTree, bmain, true);
 
 		// find the active Output Line Style node
 		for (bNode *node = (bNode *)ntree->nodes.first; node; node = node->next) {
@@ -357,8 +359,8 @@ Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, Frees
 
 void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
 {
-	if (iStrokeRep->useShadingNodes()) {
-		Material *ma = BlenderStrokeRenderer::GetStrokeShader(_context, freestyle_bmain, iStrokeRep->getLineStyle());
+	if (BKE_scene_use_new_shading_nodes(freestyle_scene)) {
+		Material *ma = BlenderStrokeRenderer::GetStrokeShader(_context, freestyle_bmain, iStrokeRep->getNodeTree());
 
 		if (strcmp(freestyle_scene->r.engine, "CYCLES") == 0) {
 			PointerRNA scene_ptr;
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
index 5150111..609909a 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
@@ -30,11 +30,12 @@
 
 extern "C" {
 struct Main;
+struct Material;
 struct Object;
 struct Render;
 struct Scene;
 struct bContext;
-struct FreestyleLineStyle;
+struct bNodeTree;
 }
 
 namespace Freestyle {
@@ -53,7 +54,7 @@ public:
 
 	Render *RenderScene(Render *re, bool render);
 
-	static Material* GetStrokeShader(bContext *C, Main *bmain, FreestyleLineStyle *linestyle);
+	static Material* GetStrokeShader(bContext *C, Main *bmain, bNodeTree *iNodeTree);
 
 protected:
 	Main *freestyle_bmain;
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
index cc92d22..2177639 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
@@ -31,7 +31,6 @@
 extern "C" {
 #include "BLI_utildefines.h" // BLI_assert()
 
-struct FreestyleLineStyle;
 struct Scene;
 struct Text;
 }
@@ -41,26 +40,15 @@ namespace Freestyle {
 class BlenderStyleModule : public StyleModule
 {
 public:
-	BlenderStyleModule(const string &name, Interpreter *inter, struct Text *text,
-	                   struct FreestyleLineStyle *lineStyle, bool useShadingNodes)
-	: StyleModule(name, inter)
+	BlenderStyleModule(struct Text *text, const string &name, Interpreter *inter) : StyleModule(name, inter)
 	{
 		_text = text;
-		_lineStyle = lineStyle;
-		_useShadingNodes = useShadingNodes;
 	}
 
 	virtual ~BlenderStyleModule()
 	{
 	}
 
-	virtual StrokeLayer *execute()
-	{
-		StrokeLayer *sl = StyleModule::execute();
-		sl->setLineStyle(_lineStyle, _useShadingNodes);
-		return sl;
-	}
-
 protected:
 	virtual int interpret()
 	{
@@ -71,8 +59,6 @@ protected:
 
 private:
 	struct Text *_text;
-	struct FreestyleLineStyle *_lineStyle;
-	bool _useShadingNodes;
 
 #ifdef WITH_CXX_GUARDEDALLOC
 	MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BlenderStyleModule")
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index f655744..c4df9c5 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -50,7 +50,6 @@ extern "C" {
 #include "BKE_library.h"
 #include "BKE_linestyle.h"
 #include "BKE_main.h"
-#include "BKE_scene.h"
 #include "BKE_text.h"
 #include "BKE_context.h"
 
@@ -295,8 +294,6 @@ static bool test_edge_type_conditions(struct edge_type_condition *conditions,
 
 static void prepare(Main *bmain, Render *re, SceneRenderLayer *srl)
 {
-	const bool use_shading_nodes = BKE_scene_use_new_shading_nodes(re->scene);
-
 	// load mesh
 	re->i.infostr = "Freestyle: Mesh loading";
 	re->stats_draw(re->sdh, &re->i);
@@ -331,7 +328,7 @@ static void prepare(Main *bmain, Render *re, SceneRenderLayer *srl)
 						cout << " (" << module_conf->script->name << ")";
 					cout << endl;
 				}
-				controller->InsertStyleModule(layer_count, id_name, module_conf->script, NULL, use_shading_nodes);
+				controller->InsertStyleModule(layer_count, id_name, module_conf->script);
 				controller->toggleLayer(layer_count, true);
 				layer_count++;
 			}
@@ -372,7 +369,7 @@ static void prepare(Main *bmain, Render *re, SceneRenderLayer *srl)
 					        (lineset->linestyle ? (lineset->linestyle->id.name + 2) : "<NULL>") << endl;
 				}
 				Text *text = create_lineset_handler(bmain, srl->name, lineset->name);
-				controller->InsertStyleModule(layer_count, lineset->name, text, lineset->linestyle, use_shading_nodes);
+				controller->InsertStyleModule(layer_count, lineset->name, text);
 				controller->toggleLayer(layer_count, true);
 				if (!(lineset->selection & FREESTYLE_SEL_EDGE_TYPES) || !lineset->edge_types) {
 					++use_ridges_and_valleys;
@@ -743,8 +740,9 @@ Material *FRS_create_stroke_material(bContext *C, Main *bmain, Scene *scene)
 
 	if (!linestyle) {
 		cout << "FRS_create_stroke_material: No active line style in the current scene" << endl;
+		return NULL;
 	}
-	return BlenderStrokeRenderer::GetStrokeShader(C, bmain, linestyle);
+	return BlenderStrokeRenderer::GetStrokeShader(C, bmain, linestyle->nodetree);
 }
 
 } // extern "C"
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
index c8b9d70..379fb7e 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp
@@ -41,38 +41,46 @@ static char BlenderTextureShader___doc__[] =
 "\n"
 "[Texture shader]\n"
 "\n"
-".. method:: __init__(LineStyleTextureSlot)\n"
+".. method:: __init__(texture)\n"
 "\n"
 "   Builds a BlenderTextureShader object.\n"
 "\n"
-"	:arg mtex: texture slot to add to stroke shading.\n"
-"   :type mtex: LineStyleTextureSlot\n"
-
+"   :arg texture: A line style texture slot or a shader node tree to define\n"
+"       a set of textures.\n"
+"   :type te

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list