diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-03-28 21:46:10 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-03-28 21:46:10 +0400 |
commit | 840ba8e8e74c74088aabf8185b91fd5e32302fee (patch) | |
tree | 2e0f229ffe129b889229c17b108777cb26aa818e /source/blender/freestyle/intern | |
parent | 009d7819c144047355c35fb1ac90333351779e3c (diff) |
Fixed the full sample anti-aliasing support in Freestyle.
The render pipeline has been extended to better work with
Freestyle stroke rendering. Struct Render has a new member
ListBase freestyle_renders to keep Render instances generated
through stroke rendering in Freestyle. The number of
elements (LinkData instances with LinkData::data pointing to a
Render instance) in freestyle_renders is the same as the scene
render layers of the scene being rendered. When the k-th scene
render layer has the Freestyle option enabled, the k-th element
of freestyle_renders refers to a Render instance that holds
Freestyle render results for the scene layer. This association
between the scene render layer and the Render instance is used to
merge the Freestyle render results into the corresponding render
results for the scene render layer.
Diffstat (limited to 'source/blender/freestyle/intern')
5 files changed, 65 insertions, 57 deletions
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp index 43f091d3fa1..76c9023df57 100755 --- a/source/blender/freestyle/intern/application/Controller.cpp +++ b/source/blender/freestyle/intern/application/Controller.cpp @@ -676,8 +676,13 @@ void Controller::DrawStrokes() resetModified(); } +void Controller::ResetRenderCount() +{ + _render_count = 0; +} + Render* Controller::RenderStrokes(Render *re) { - BlenderStrokeRenderer* blenderRenderer = new BlenderStrokeRenderer(re); + BlenderStrokeRenderer* blenderRenderer = new BlenderStrokeRenderer(re, ++_render_count); _Canvas->Render( blenderRenderer ); Render* freestyle_render = blenderRenderer->RenderScene(re); delete blenderRenderer; diff --git a/source/blender/freestyle/intern/application/Controller.h b/source/blender/freestyle/intern/application/Controller.h index 9d1db24a026..deeabb6da0a 100755 --- a/source/blender/freestyle/intern/application/Controller.h +++ b/source/blender/freestyle/intern/application/Controller.h @@ -85,6 +85,7 @@ public: void saveSteerableViewMapImages(); void toggleEdgeTesselationNature(Nature::EdgeNature iNature); void DrawStrokes(); + void ResetRenderCount(); Render* RenderStrokes(Render *re); void SwapStyleModules(unsigned i1, unsigned i2); void InsertStyleModule(unsigned index, const char *iFileName); @@ -204,6 +205,7 @@ private: real _EPSILON; real _bboxDiag; + int _render_count; //AppStyleWindow *_pStyleWindow; //AppOptionsWindow *_pOptionsWindow; diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index f6798384f0a..c7b4b681958 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -32,7 +32,7 @@ extern "C" { #endif -BlenderStrokeRenderer::BlenderStrokeRenderer(Render* re) +BlenderStrokeRenderer::BlenderStrokeRenderer(Render* re, int render_count) :StrokeRenderer(){ // TEMPORARY - need a texture manager @@ -45,7 +45,9 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render* re) objects.first = objects.last = NULL; ListBase lb; - freestyle_scene = add_scene("freestyle_strokes"); + char name[22]; + snprintf(name, sizeof(name), "FRS%d_%s", render_count, re->scene->id.name+2); + freestyle_scene = add_scene(name); lb = freestyle_scene->r.layers; freestyle_scene->r= old_scene->r; freestyle_scene->r.layers= lb; @@ -95,9 +97,6 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer(){ _textureManager = 0; } - // release scene - free_libblock( &G.main->scene, freestyle_scene ); - // release objects and data blocks LinkData *link = (LinkData *)objects.first; while(link) { diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h index 5bee116457d..3f2b2a1128c 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h @@ -23,7 +23,7 @@ extern "C" { class LIB_STROKE_EXPORT BlenderStrokeRenderer : public StrokeRenderer { public: - BlenderStrokeRenderer(Render *re); + BlenderStrokeRenderer(Render *re, int render_count); virtual ~BlenderStrokeRenderer(); /*! Renders a stroke rep */ diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 0ea3280c1bc..001da72771b 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -185,7 +185,7 @@ extern "C" { controller->ComputeViewMap(); } - void composite_result(Render* re, SceneRenderLayer* srl, Render* freestyle_render) + void FRS_composite_result(Render* re, SceneRenderLayer* srl, Render* freestyle_render) { RenderLayer *rl; @@ -230,64 +230,66 @@ extern "C" { } return count; } + + int FRS_is_freestyle_enabled(SceneRenderLayer* srl) { + return (!(srl->layflag & SCE_LAY_DISABLE) && + srl->layflag & SCE_LAY_FRS && + displayed_layer_count(srl) > 0); + } - void FRS_add_Freestyle(Render* re) { - - SceneRenderLayer *srl; - Render* freestyle_render = NULL; - - // init + void FRS_init_stroke_rendering(Render* re) { + cout << "\n#===============================================================" << endl; cout << "# Freestyle" << endl; cout << "#===============================================================" << endl; init_view(re); init_camera(re); - freestyle_scene = re->scene; + + controller->ResetRenderCount(); + } + + Render* FRS_do_stroke_rendering(Render* re, SceneRenderLayer *srl) { - for(srl= (SceneRenderLayer *)re->scene->r.layers.first; srl; srl= srl->next) { - if( !(srl->layflag & SCE_LAY_DISABLE) && - srl->layflag & SCE_LAY_FRS && - displayed_layer_count(srl) > 0 ) - { - cout << "\n----------------------------------------------------------" << endl; - cout << "| " << (re->scene->id.name+2) << "|" << srl->name << endl; - cout << "----------------------------------------------------------" << endl; - - // prepare Freestyle: - // - clear canvas - // - load mesh - // - add style modules - // - set parameters - // - compute view map - prepare(re, srl); - - if( re->test_break(re->tbh) ) { - controller->CloseFile(); - break; - } - - // render and composite Freestyle result - if( controller->_ViewMap ) { - - // render strokes - re->i.infostr= "Freestyle: Stroke rendering"; - re->stats_draw(re->sdh, &re->i); - re->i.infostr= NULL; - controller->DrawStrokes(); - freestyle_render = controller->RenderStrokes(re); - controller->CloseFile(); - - // composite result - composite_result(re, srl, freestyle_render); - - // free resources - RE_FreeRender(freestyle_render); - } - } - } + Render* freestyle_render = NULL; - freestyle_scene = NULL; + cout << "\n----------------------------------------------------------" << endl; + cout << "| " << (re->scene->id.name+2) << "|" << srl->name << endl; + cout << "----------------------------------------------------------" << endl; + + // prepare Freestyle: + // - clear canvas + // - load mesh + // - add style modules + // - set parameters + // - compute view map + prepare(re, srl); + + if( re->test_break(re->tbh) ) { + controller->CloseFile(); + return NULL; + } + + // render and composite Freestyle result + if( controller->_ViewMap ) { + + // render strokes + re->i.infostr= "Freestyle: Stroke rendering"; + re->stats_draw(re->sdh, &re->i); + re->i.infostr= NULL; + freestyle_scene = re->scene; + controller->DrawStrokes(); + freestyle_render = controller->RenderStrokes(re); + controller->CloseFile(); + freestyle_scene = NULL; + + // composite result + FRS_composite_result(re, srl, freestyle_render); + RE_FreeRenderResult(freestyle_render->result); + freestyle_render->result = NULL; + } + + return freestyle_render; } //======================================================= |