[Bf-blender-cvs] [c38e80d] master: WIP commit just for a record of a working snapshot of code revisions for node-based textured strokes.
Tamito Kajiyama
noreply at git.blender.org
Tue Aug 12 03:17:51 CEST 2014
Commit: c38e80d6322b942fd2a893f4f294a919ed6e6b99
Author: Tamito Kajiyama
Date: Sat Jul 19 15:38:56 2014 +0900
Branches: master
https://developer.blender.org/rBc38e80d6322b942fd2a893f4f294a919ed6e6b99
WIP commit just for a record of a working snapshot of code revisions for node-based textured strokes.
===================================================================
M intern/cycles/blender/blender_mesh.cpp
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/BlenderStyleModule.h
M source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
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
===================================================================
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index f07f0fd..364ee9a 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -408,17 +408,30 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
float3 *fdata = attr->data_float3();
size_t i = 0;
+ std::cout << "name " << name << std::endl;
for(l->data.begin(t); t != l->data.end(); ++t, ++i) {
fdata[0] = get_float3(t->uv1());
fdata[1] = get_float3(t->uv2());
fdata[2] = get_float3(t->uv3());
fdata += 3;
+#if 0
+ std::cout << " 1st "
+ << "( " << t->uv1()[0] << ", " << t->uv1()[1] << ") "
+ << "( " << t->uv2()[0] << ", " << t->uv2()[1] << ") "
+ << "( " << t->uv3()[0] << ", " << t->uv3()[1] << ") " << std::endl;
+#endif
if(nverts[i] == 4) {
fdata[0] = get_float3(t->uv1());
fdata[1] = get_float3(t->uv3());
fdata[2] = get_float3(t->uv4());
fdata += 3;
+#if 0
+ std::cout << " 2nd "
+ << "( " << t->uv1()[0] << ", " << t->uv1()[1] << ") "
+ << "( " << t->uv3()[0] << ", " << t->uv3()[1] << ") "
+ << "( " << t->uv4()[0] << ", " << t->uv4()[1] << ") " << std::endl;
+#endif
}
}
}
diff --git a/release/scripts/freestyle/modules/parameter_editor.py b/release/scripts/freestyle/modules/parameter_editor.py
index 3016130..995a917 100644
--- a/release/scripts/freestyle/modules/parameter_editor.py
+++ b/release/scripts/freestyle/modules/parameter_editor.py
@@ -1075,7 +1075,21 @@ def process(layer_name, lineset_name):
elif m.type == '2D_TRANSFORM':
shaders_list.append(Transform2DShader(
m.pivot, m.scale_x, m.scale_y, m.angle, m.pivot_u, m.pivot_x, m.pivot_y))
-
+ has_tex = False
+ if scene.render.use_shading_nodes:
+ if linestyle.use_nodes and linestyle.node_tree:
+ ### TODO ###
+ #shaders_list.append(BlenderTextureShader(linestyle.nodetree))
+ has_tex = True
+ else:
+ if linestyle.use_texture:
+ for slot in linestyle.texture_slots:
+ if slot is not None:
+ shaders_list.append(BlenderTextureShader(slot))
+ has_tex = True
+ if has_tex:
+ shaders_list.append(StrokeTextureStepShader(linestyle.texture_spacing))
+ color = linestyle.color
if (not linestyle.use_chaining) or (linestyle.chaining == 'PLAIN' and linestyle.use_same_object):
thickness_position = linestyle.thickness_position
else:
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index e4bfdb2..4fd58ab 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -892,10 +892,10 @@ void Controller::InsertStyleModule(unsigned index, const char *iFileName)
_Canvas->InsertStyleModule(index, sm);
}
-void Controller::InsertStyleModule(unsigned index, const char *iName, struct FreestyleLineStyle *iLineStyle,
- struct Text *iText)
+void Controller::InsertStyleModule(unsigned index, const char *iName, struct Text *iText,
+ struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes)
{
- StyleModule *sm = new BlenderStyleModule(iText, iLineStyle, iName, _inter);
+ StyleModule *sm = new BlenderStyleModule(iName, _inter, iText, iLineStyle, iUseShadingNodes);
_Canvas->InsertStyleModule(index, sm);
}
diff --git a/source/blender/freestyle/intern/application/Controller.h b/source/blender/freestyle/intern/application/Controller.h
index d2b865d..c4f2596 100644
--- a/source/blender/freestyle/intern/application/Controller.h
+++ b/source/blender/freestyle/intern/application/Controller.h
@@ -89,8 +89,8 @@ 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 FreestyleLineStyle *iLineStyle,
- struct Text *iText);
+ void InsertStyleModule(unsigned index, const char *iName, struct Text *iText,
+ struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes);
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 b119b10..a9ab69c 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -52,6 +52,7 @@ extern "C" {
#include "BKE_object.h"
#include "BKE_scene.h"
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "RE_pipeline.h"
@@ -330,6 +331,22 @@ Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, Frees
outsock = (bNodeSocket *)BLI_findlink(&output_linestyle->inputs, 2); // Alpha
outsock = (bNodeSocket *)BLI_findlink(&output_linestyle->inputs, 3); // Alpha Fac
#endif
+
+#if 0
+ for (bNode *node = (bNode *)ntree->nodes.first; node; node = node->next) {
+ if (node->type == SH_NODE_TEX_IMAGE) {
+ bNode *input_uvmap = nodeAddStaticNode(C, ntree, SH_NODE_UVMAP);
+ input_uvmap->locx = node->locx - 200.0f;
+ input_uvmap->locy = node->locy;
+ NodeShaderUVMap *storage = (NodeShaderUVMap *)input_uvmap->storage;
+ BLI_strncpy(storage->uv_map, "along_stroke_tips", sizeof(storage->uv_map));
+
+ fromsock = (bNodeSocket *)BLI_findlink(&input_uvmap->outputs, 0); // UV
+ tosock = (bNodeSocket *)BLI_findlink(&node->inputs, 0); // Vector
+ nodeAddLink(ntree, input_uvmap, fromsock, node, tosock);
+ }
+ }
+#endif
}
nodeSetActive(ntree, shader_mix);
@@ -340,7 +357,7 @@ Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, Frees
void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
{
- if (BKE_scene_use_new_shading_nodes(freestyle_scene)) {
+ if (iStrokeRep->useShadingNodes()) {
Material *ma = BlenderStrokeRenderer::GetStrokeShader(_context, freestyle_bmain, iStrokeRep->getLineStyle());
if (strcmp(freestyle_scene->r.engine, "CYCLES") == 0) {
@@ -464,7 +481,7 @@ void BlenderStrokeRenderer::test_strip_visibility(Strip::vertex_container& strip
void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
{
vector<Strip*>& strips = iStrokeRep->getStrips();
- const bool hasTex = iStrokeRep->getMTex(0) != NULL;
+ const bool hasTex = iStrokeRep->hasTex();
Strip::vertex_container::iterator v[3];
StrokeVertexRep *svRep[3];
unsigned int vertex_index, edge_index, loop_index;
@@ -535,7 +552,7 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
CustomData_add_layer_named(&mesh->ldata, CD_MLOOPUV, CD_CALLOC, NULL, mesh->totloop, "along_stroke");
CustomData_set_layer_active(&mesh->pdata, CD_MTEXPOLY, 0);
CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 0);
- BKE_mesh_update_customdata_pointers(mesh, true);
+ BKE_mesh_update_customdata_pointers(mesh, false);
loopsuv[0] = mesh->mloopuv;
@@ -544,7 +561,7 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
CustomData_add_layer_named(&mesh->ldata, CD_MLOOPUV, CD_CALLOC, NULL, mesh->totloop, "along_stroke_tips");
CustomData_set_layer_active(&mesh->pdata, CD_MTEXPOLY, 1);
CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 1);
- BKE_mesh_update_customdata_pointers(mesh, true);
+ BKE_mesh_update_customdata_pointers(mesh, false);
loopsuv[1] = mesh->mloopuv;
}
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
index ad656fd..cc92d22 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
@@ -29,12 +29,11 @@
#include "../system/PythonInterpreter.h"
extern "C" {
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_text.h"
-#include "BLI_utildefines.h"
+#include "BLI_utildefines.h" // BLI_assert()
struct FreestyleLineStyle;
+struct Scene;
+struct Text;
}
namespace Freestyle {
@@ -42,11 +41,13 @@ namespace Freestyle {
class BlenderStyleModule : public StyleModule
{
public:
- BlenderStyleModule(struct Text *text, struct FreestyleLineStyle *linestyle, const string &name,
- Interpreter *inter) : StyleModule(name, inter)
+ BlenderStyleModule(const string &name, Interpreter *inter, struct Text *text,
+ struct FreestyleLineStyle *lineStyle, bool useShadingNodes)
+ : StyleModule(name, inter)
{
_text = text;
- _linestyle = linestyle;
+ _lineStyle = lineStyle;
+ _useShadingNodes = useShadingNodes;
}
virtual ~BlenderStyleModule()
@@ -55,9 +56,8 @@ public:
virtual StrokeLayer *execute()
{
-
StrokeLayer *sl = StyleModule::execute();
- sl->setLineStyle(_linestyle);
+ sl->setLineStyle(_lineStyle, _useShadingNodes);
return sl;
}
@@ -71,7 +71,8 @@ protected:
private:
struct Text *_text;
- struct FreestyleLineStyle *_linestyle;
+ 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 e662be0..f655744 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -50,6 +50,7 @@ extern "C" {
#include "BKE_library.h"
#include "BKE_linestyle.h"
#include "BKE_main.h"
+#include "BKE_scene.h"
#include "BKE_text.h"
#include "BKE_cont
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list