diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2014-07-15 19:21:27 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2014-08-12 05:10:20 +0400 |
commit | fc85446c500fbe70515567e94122fc0d8746f3e5 (patch) | |
tree | f468d3d79cf395ea443682cdb1a92b42640e2550 /source/blender/freestyle/intern/stroke | |
parent | 4677684cfd18ea92f72bc5f24dc453cb1919e513 (diff) |
Freestyle: Added preliminary support for textured strokes in Cycles.
Now the shader node tree of a line style ID datablock is used to define textures
as well as their mapping and influence.
TODO: Textures alpha channel mapping and influence.
TODO: Blend mode in the Output Line Style shader node.
Diffstat (limited to 'source/blender/freestyle/intern/stroke')
7 files changed, 38 insertions, 1 deletions
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp index c85295e72bf..158ceea93a3 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.cpp +++ b/source/blender/freestyle/intern/stroke/Stroke.cpp @@ -774,6 +774,13 @@ void Stroke::ScaleThickness(float iFactor) } } +void Stroke::SetLineStyle(struct FreestyleLineStyle *iLineStyle) +{ + if (!_rep) + _rep = new StrokeRep(this); + _rep->setLineStyle(iLineStyle); +} + void Stroke::Render(const StrokeRenderer *iRenderer) { if (!_rep) diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h index abbbcc32750..e18e176baba 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.h +++ b/source/blender/freestyle/intern/stroke/Stroke.h @@ -45,6 +45,8 @@ extern "C" { #include "DNA_material_types.h" + +struct FreestyleLineStyle; } #ifndef MAX_MTEX @@ -623,6 +625,7 @@ public: /* Render method */ void ScaleThickness(float iFactor); + void SetLineStyle(struct FreestyleLineStyle *iLineStyle); void Render(const StrokeRenderer *iRenderer); void RenderBasic(const StrokeRenderer *iRenderer); diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp index 67552d6ebf2..14251162168 100644 --- a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp @@ -43,6 +43,13 @@ void StrokeLayer::ScaleThickness(float iFactor) } } +void StrokeLayer::SetLineStyle(struct FreestyleLineStyle *iLineStyle) +{ + for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; ++s) { + (*s)->SetLineStyle(iLineStyle); + } +} + void StrokeLayer::Render(const StrokeRenderer *iRenderer) { for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; ++s) { diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.h b/source/blender/freestyle/intern/stroke/StrokeLayer.h index 91292e237d6..93eca3be8c7 100644 --- a/source/blender/freestyle/intern/stroke/StrokeLayer.h +++ b/source/blender/freestyle/intern/stroke/StrokeLayer.h @@ -34,6 +34,10 @@ #include "MEM_guardedalloc.h" #endif +extern "C" { +struct FreestyleLineStyle; +} + namespace Freestyle { class Stroke; @@ -63,6 +67,7 @@ public: /*! Render method */ void ScaleThickness(float iFactor); + void SetLineStyle(struct FreestyleLineStyle *iLineStyle); void Render(const StrokeRenderer *iRenderer); void RenderBasic(const StrokeRenderer *iRenderer); diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp index 3f39443c4b8..25e242b9dbe 100644 --- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp @@ -704,6 +704,7 @@ StrokeRep::StrokeRep() { _stroke = 0; _strokeType = Stroke::OPAQUE_MEDIUM; + _lineStyle = NULL; _textureStep = 1.0; for (int a = 0; a < MAX_MTEX; a++) { _mtex[a] = NULL; @@ -724,6 +725,7 @@ StrokeRep::StrokeRep(Stroke *iStroke) { _stroke = iStroke; _strokeType = iStroke->getMediumType(); + _lineStyle = NULL; _textureId = iStroke->getTextureId(); _textureStep = iStroke->getTextureStep(); for (int a = 0; a < MAX_MTEX; a++) { @@ -757,6 +759,7 @@ StrokeRep::StrokeRep(const StrokeRep& iBrother) _strokeType = iBrother._strokeType; _textureId = iBrother._textureId; _textureStep = iBrother._textureStep; + _lineStyle = iBrother._lineStyle; for (int a = 0; a < MAX_MTEX; a++) { if (iBrother._mtex[a]) { _mtex[a] = iBrother._mtex[a]; diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.h b/source/blender/freestyle/intern/stroke/StrokeRep.h index 50615e0c571..dad36cd01ed 100644 --- a/source/blender/freestyle/intern/stroke/StrokeRep.h +++ b/source/blender/freestyle/intern/stroke/StrokeRep.h @@ -38,6 +38,7 @@ extern "C" { #include "DNA_material_types.h" // for MAX_MTEX +struct FreestyleLineStyle; } namespace Freestyle { @@ -186,6 +187,7 @@ protected: float _textureStep; MTex *_mtex[MAX_MTEX]; Material *_material; + FreestyleLineStyle *_lineStyle; // float _averageTextureAlpha; @@ -222,6 +224,11 @@ public: return _material; } + inline FreestyleLineStyle *getLineStyle() const + { + return _lineStyle; + } + inline vector<Strip*>& getStrips() { return _strips; @@ -258,6 +265,11 @@ public: _mtex[idx] = mtex_ptr; }*/ + inline void setLineStyle(FreestyleLineStyle *iLineStyle) + { + _lineStyle = iLineStyle; + } + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeRep") #endif diff --git a/source/blender/freestyle/intern/stroke/StyleModule.h b/source/blender/freestyle/intern/stroke/StyleModule.h index f1d96283f90..86127e7a592 100644 --- a/source/blender/freestyle/intern/stroke/StyleModule.h +++ b/source/blender/freestyle/intern/stroke/StyleModule.h @@ -62,7 +62,7 @@ public: virtual ~StyleModule() {} - StrokeLayer *execute() + virtual StrokeLayer *execute() { if (!_inter) { cerr << "Error: no interpreter was found to execute the script" << endl; |