Freestyle's pipeline is now fully controllable at the layer level. It can be used:
 - in any render layer
 - with as many style modules per layer

DETAILS:
Freestyle usage has not changed:
  - all the configuration happens in the "Freestyle" render panel, after it is enabled in the "Output" panel with the 'Freestyle' toggle.
  - each render layer can choose to render Freestyle strokes by togglingo on 'FrSt' (in the "Render Layers" panel)
  - it is fully compatible with compositor nodes

In the "Freestyle" panel, a render layer is selected via the menu list next to the "Render Layer:" label. The options displayed below are those of the currently selected render layer (and are not global to all render layers, as was previously the case).

Style modules are added by pressing the lower button "Add style module". Once added, the following operations are possible:
- deletion (cross)
- reordering (up/down arrows)
- toggling of display (check)

The order of the style modules follows Freestyle's original convention: the modules in the list from top to bottom are respectively the first to the last composited in the render layer. For example, if the module list is "contour" followed by "cartoon", the "cartoon" strokes are rendered on top of the "contour" strokes.

The "Freestyle" panel is constantly synchronized with the "Render Layers" panel: if render layers are added, deleted or toggled off display, Freestyle will take note of the changes.

The current pipeline works as follows:

----------------------------------------------------------------------------------------------
for every scene that is being rendered
	if Freestyle is enabled globally
	
		Freestyle is initialized
		camera and view settings are transferred from Blender to Freestyle
		
		for every render layer
			if: - layer is enabled 
			    - layer enabled Freestyle
			    - the number of displayed style modules is non-zero
				
				canvas is cleared
				geometry is transferred from Blender to Freestyle
				settings are fixed for current iteration
				view map is calculated
				
				strokes are computed in the canvas (based on view map and style modules)
				strokes are rendered in separate Blender scene
				
				scene is composited in current layer
----------------------------------------------------------------------------------------------

A number of changes were made on the codebase:
- the rendering interface between Freestyle and Blender was simplified. The following naming convention was used: functions that are called from within Blender pipeline are prefixed with 'FRS_', while the variables are prefixed with 'freestyle_'
- Freestyle data structures that were put in Blender's render pipeline were removed
- Freestyle cleans up its data structures on Blender exit and shouldn't leak memory
- to ease the configuration in the "Freestyle" panel, a centralized configuration data structure was used and can be easily extended

LIMITATIONS
Even though the current commit is stable and achieves the intended result, it is not as efficient as it could be:
- the canvas and the style modules are at cleared at each layer-level render
- geometry is reloaded at each frame and is duplicated across render layers

This revision clarifies my understanding of the future role of the view map in the compositor. Unfortunately, contrary to what the original proposal said, it is impossible to provide the view map as a render pass because render passes are defined (RE_pipeline.h) as raw floating-point rects. We will have to determine whether or not to extend the notion of render pass to fully integrate the view map in the compositor.
This commit is contained in:
Maxime Curioni
2009-04-07 18:38:23 +00:00
parent 6225d2d3f9
commit 5dd39e6517
16 changed files with 399 additions and 206 deletions

View File

@@ -8,10 +8,15 @@
extern "C" {
#endif
extern char style_module[255];
extern int freestyle_flags;
extern float freestyle_sphere_radius;
extern float freestyle_dkr_epsilon;
typedef struct StyleModuleConf {
struct StyleModuleConf *next, *prev;
char module_path[255];
short is_displayed;
} StyleModuleConf;
extern short freestyle_is_initialized;
extern float freestyle_fovyradian;
extern float freestyle_viewpoint[3];
@@ -19,11 +24,27 @@ extern "C" {
extern float freestyle_proj[4][4];
extern int freestyle_viewport[4];
extern short freestyle_current_layer_number;
extern char* freestyle_current_module_path;
extern SceneRenderLayer* freestyle_current_layer;
extern ListBase* freestyle_modules;
extern int* freestyle_flags;
extern float* freestyle_sphere_radius;
extern float* freestyle_dkr_epsilon;
// Rendering
void FRS_initialize();
void FRS_prepare(Render* re);
void FRS_render_Blender(Render* re);
void FRS_composite_result(Render* re, SceneRenderLayer* srl);
void FRS_add_Freestyle(Render* re);
void FRS_exit();
// Panel configuration
void FRS_select_layer( SceneRenderLayer* srl );
void FRS_delete_layer( SceneRenderLayer* srl, short isDestructor );
void FRS_add_module();
void FRS_delete_module(void *module_index_ptr, void *unused);
void FRS_move_up_module(void *module_index_ptr, void *unused);
void FRS_move_down_module(void *module_index_ptr, void *unused);
void FRS_set_module_path(void *module_index_ptr, void *unused);
#ifdef __cplusplus
}

View File

@@ -175,10 +175,10 @@ void Controller::setView(AppView *iView)
_Canvas->setViewer(_pView);
}
int Controller::LoadMesh(Render *re)
int Controller::LoadMesh(Render *re, SceneRenderLayer* srl)
{
BlenderFileLoader loader(re);
BlenderFileLoader loader(re, srl);
_Chrono.start();
@@ -640,11 +640,12 @@ void Controller::DrawStrokes()
resetModified();
}
void Controller::RenderBlender(Render *re) {
Render* Controller::RenderStrokes(Render *re) {
BlenderStrokeRenderer* blenderRenderer = new BlenderStrokeRenderer;
_Canvas->Render( blenderRenderer );
blenderRenderer->RenderScene(re);
Render* freestyle_render = blenderRenderer->RenderScene(re);
blenderRenderer->Close();
return freestyle_render;
}
void Controller::InsertStyleModule(unsigned index, const char *iFileName)

View File

@@ -57,6 +57,7 @@ extern "C" {
#endif
#include "render_types.h"
#include "DNA_scene_types.h"
#ifdef __cplusplus
}
@@ -73,15 +74,15 @@ public:
//soc
void init_options();
int LoadMesh( Render *re );
int LoadMesh( Render *re, SceneRenderLayer* srl );
int Load3DSFile(const char *iFileName);
void CloseFile();
void ComputeViewMap();
void ComputeSteerableViewMap();
void saveSteerableViewMapImages();
void toggleEdgeTesselationNature(Nature::EdgeNature iNature);
void RenderBlender(Render *re);
void DrawStrokes();
void DrawStrokes();
Render* RenderStrokes(Render *re);
void SwapStyleModules(unsigned i1, unsigned i2);
void InsertStyleModule(unsigned index, const char *iFileName);
void AddStyleModule(const char *iFileName);

View File

@@ -4,70 +4,108 @@
#include "AppCanvas.h"
#include <iostream>
#ifdef __cplusplus
extern "C" {
#endif
#include "../../FRS_freestyle.h"
#include "DNA_camera_types.h"
#include "DNA_scene_types.h"
#include "render_types.h"
#include "renderpipeline.h"
#include "pixelblending.h"
#include "BLI_blenlib.h"
#include "BIF_renderwin.h"
#include "BPY_extern.h"
#ifdef __cplusplus
}
#endif
#include <map>
#include <set>
using namespace std;
#ifdef __cplusplus
extern "C" {
#endif
#include "MEM_guardedalloc.h"
#include "DNA_camera_types.h"
#include "DNA_listBase.h"
#include "DNA_scene_types.h"
#include "BKE_global.h"
#include "BLI_blenlib.h"
#include "BIF_renderwin.h"
#include "BPY_extern.h"
#include "render_types.h"
#include "renderpipeline.h"
#include "pixelblending.h"
#include "../../FRS_freestyle.h"
// Freestyle configuration
short freestyle_is_initialized = 0;
static Config::Path *pathconfig = NULL;
static Controller *controller = NULL;
static AppView *view = NULL;
char style_module[255] = "";
int freestyle_flags;
float freestyle_sphere_radius = 1.0;
float freestyle_dkr_epsilon = 0.001;
// camera information
float freestyle_viewpoint[3];
float freestyle_mv[4][4];
float freestyle_proj[4][4];
int freestyle_viewport[4];
// Panel configuration
short freestyle_current_layer_number = 0;
char* freestyle_current_module_path = NULL;
SceneRenderLayer* freestyle_current_layer = NULL;
ListBase* freestyle_modules;
int* freestyle_flags;
float* freestyle_sphere_radius;
float* freestyle_dkr_epsilon;
class FreestylePanelConfigurationData {
public:
set<SceneRenderLayer*> layers;
map<SceneRenderLayer*, ListBase*> modules;
map<SceneRenderLayer*, int*> flags;
map<SceneRenderLayer*, float*> sphere_radius;
map<SceneRenderLayer*, float*> dkr_epsilon;
FreestylePanelConfigurationData() {}
~FreestylePanelConfigurationData() {
set<SceneRenderLayer*>::iterator it;
for( it=layers.begin(); it!=layers.end(); it++)
FRS_delete_layer( *it, 1 );
}
};
static FreestylePanelConfigurationData* panelConfig;
string default_module_path;
//=======================================================
// Initialization
//=======================================================
void FRS_initialize(){
if( pathconfig == NULL )
if( !freestyle_is_initialized ) {
pathconfig = new Config::Path;
if( controller == NULL )
controller = new Controller;
if( view == NULL ) {
view = new AppView;
controller->setView(view);
}
if( strlen(style_module) == 0 ){
string path( pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py" );
strcpy( style_module, path.c_str() );
panelConfig = new FreestylePanelConfigurationData;
default_module_path = pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py";
FRS_select_layer( (SceneRenderLayer*) BLI_findlink(&G.scene->r.layers, G.scene->r.actlay) );
freestyle_is_initialized = 1;
}
}
void FRS_exit() {
delete pathconfig;
delete controller;
delete view;
delete panelConfig;
}
//=======================================================
// Rendering
//=======================================================
void FRS_init_view(Render* re){
void init_view(Render* re){
int width = re->scene->r.xsch;
int height = re->scene->r.ysch;
@@ -79,7 +117,7 @@ extern "C" {
view->setHeight( height );
}
void FRS_init_camera(Render* re){
void init_camera(Render* re){
Object* maincam_obj = re->scene->camera;
Camera *cam = (Camera*) maincam_obj->data;
@@ -115,29 +153,34 @@ extern "C" {
}
void FRS_prepare(Render* re) {
void prepare(Render* re, SceneRenderLayer* srl ) {
// init
FRS_initialize();
FRS_init_view(re);
FRS_init_camera(re);
// clear canvas
controller->Clear();
// load mesh
if( controller->LoadMesh(re) ) // returns if scene cannot be loaded or if empty
if( controller->LoadMesh(re, srl) ) // returns if scene cannot be loaded or if empty
return;
// add style module
cout << "\n=== Rendering options ===" << endl;
cout << "Module: " << style_module << endl;
controller->InsertStyleModule( 0, style_module );
controller->toggleLayer(0, true);
// add style modules
cout << "\n=== Rendering options ===" << endl;
cout << "Modules :"<< endl;
int layer_count = 0;
for( StyleModuleConf* module_conf = (StyleModuleConf *)panelConfig->modules[srl]->first; module_conf; module_conf = module_conf->next ) {
if( module_conf->is_displayed ) {
cout << " " << layer_count+1 << ": " << module_conf->module_path << endl;
controller->InsertStyleModule( layer_count, module_conf->module_path );
controller->toggleLayer(layer_count, true);
layer_count++;
}
}
cout << endl;
// set parameters
controller->setSphereRadius(freestyle_sphere_radius);
controller->setComputeRidgesAndValleysFlag((freestyle_flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false);
controller->setComputeSuggestiveContoursFlag((freestyle_flags & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false);
controller->setSuggestiveContourKrDerivativeEpsilon(freestyle_dkr_epsilon);
controller->setSphereRadius(*panelConfig->sphere_radius[srl]);
controller->setComputeRidgesAndValleysFlag((*panelConfig->flags[srl] & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false);
controller->setComputeSuggestiveContoursFlag((*panelConfig->flags[srl] & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false);
controller->setSuggestiveContourKrDerivativeEpsilon(*panelConfig->dkr_epsilon[srl]);
cout << "Sphere radius : " << controller->getSphereRadius() << endl;
cout << "Redges and valleys : " << (controller->getComputeRidgesAndValleysFlag() ? "enabled" : "disabled") << endl;
@@ -148,33 +191,17 @@ extern "C" {
controller->ComputeViewMap();
}
void FRS_render_Blender(Render* re) {
if( controller->_ViewMap ) {
cout << "\n=== Rendering Freestyle with Blender's internal renderer ===" << endl;
// build strokes
controller->DrawStrokes();
controller->RenderBlender(re);
controller->CloseFile();
} else {
cout << "Freestyle cannot be used because the view map is not available" << endl;
}
cout << "\n###################################################################" << endl;
}
void FRS_composite_result(Render* re, SceneRenderLayer* srl)
void composite_result(Render* re, SceneRenderLayer* srl, Render* freestyle_render)
{
RenderLayer *rl;
float *src, *dest, *pixSrc, *pixDest;
int x, y, rectx, recty;
if( re->freestyle_render == NULL || re->freestyle_render->result == NULL )
if( freestyle_render == NULL || freestyle_render->result == NULL )
return;
rl = render_get_active_layer( re->freestyle_render, re->freestyle_render->result );
rl = render_get_active_layer( freestyle_render, freestyle_render->result );
if( !rl || rl->rectf == NULL) { cout << "Cannot find Freestyle result image" << endl; return; }
src = rl->rectf;
@@ -198,21 +225,150 @@ extern "C" {
}
int displayed_layer_count( SceneRenderLayer* srl ) {
int count = 0;
for( StyleModuleConf* module_conf = (StyleModuleConf *)panelConfig->modules[srl]->first; module_conf; module_conf = module_conf->next ) {
if( module_conf->is_displayed )
count++;
}
return count;
}
void FRS_add_Freestyle(Render* re) {
SceneRenderLayer *srl, *freestyle_srl = NULL;
for(srl= (SceneRenderLayer *)re->scene->r.layers.first; srl && (freestyle_srl == NULL); srl= srl->next) {
if(srl->layflag & SCE_LAY_FRS) {
if (!freestyle_srl) freestyle_srl = srl;
SceneRenderLayer *srl;
Render* freestyle_render = NULL;
// init
cout << "\n#===============================================================" << endl;
cout << "# Freestyle" << endl;
cout << "#===============================================================" << endl;
FRS_initialize();
init_view(re);
init_camera(re);
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 << "| "<< srl->name << endl;
cout << "----------------------------------------------------------" << endl;
// prepare Freestyle:
// - clear canvas
// - load mesh
// - add style modules
// - set parameters
// - compute view map
prepare(re, srl);
// render and composite Freestyle result
if( controller->_ViewMap ) {
// render strokes
controller->DrawStrokes();
freestyle_render = controller->RenderStrokes(re);
controller->CloseFile();
// composite result
composite_result(re, srl, freestyle_render);
// free resources
RE_FreeRender(freestyle_render);
}
}
}
if( freestyle_srl ) {
FRS_prepare(re);
FRS_render_Blender(re);
FRS_composite_result(re, freestyle_srl);
}
}
//=======================================================
// Freestyle Panel Configuration
//=======================================================
void FRS_select_layer( SceneRenderLayer* srl )
{
if( panelConfig->layers.find(srl) == panelConfig->layers.end() )
{
panelConfig->layers.insert(srl);
panelConfig->modules[srl] = new ListBase;
panelConfig->modules[srl]->first = panelConfig->modules[srl]->last = NULL;
panelConfig->flags[srl] = new int(0);
panelConfig->sphere_radius[srl] = new float(1.0);
panelConfig->dkr_epsilon[srl] = new float(0.001);
}
freestyle_modules = panelConfig->modules[srl];
freestyle_flags = panelConfig->flags[srl];
freestyle_sphere_radius = panelConfig->sphere_radius[srl];
freestyle_dkr_epsilon = panelConfig->dkr_epsilon[srl];
freestyle_current_layer = srl;
freestyle_current_layer_number = BLI_findindex(&G.scene->r.layers, freestyle_current_layer);
}
void FRS_delete_layer( SceneRenderLayer* srl, short isDestructor )
{
BLI_freelistN( panelConfig->modules[srl] );
delete panelConfig->modules[srl];
delete panelConfig->flags[srl];
delete panelConfig->sphere_radius[srl];
delete panelConfig->dkr_epsilon[srl];
panelConfig->modules.erase(srl);
panelConfig->flags.erase(srl);
panelConfig->sphere_radius.erase(srl);
panelConfig->dkr_epsilon.erase(srl);
if( !isDestructor )
panelConfig->layers.erase(srl);
}
void FRS_add_module()
{
StyleModuleConf* module_conf = (StyleModuleConf*) MEM_callocN( sizeof(StyleModuleConf), "style module configuration");
BLI_addtail(freestyle_modules, (void*) module_conf);
strcpy( module_conf->module_path, default_module_path.c_str() );
module_conf->is_displayed = 1;
}
void FRS_delete_module(void *module_index_ptr, void *unused)
{
StyleModuleConf* module_conf = (StyleModuleConf*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
BLI_freelinkN( freestyle_modules, module_conf);
}
void FRS_move_up_module(void *module_index_ptr, void *unused)
{
StyleModuleConf* module_conf = (StyleModuleConf*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
BLI_remlink(freestyle_modules, module_conf);
BLI_insertlink(freestyle_modules, module_conf->prev->prev, module_conf);
}
void FRS_move_down_module(void *module_index_ptr, void *unused)
{
StyleModuleConf* module_conf = (StyleModuleConf*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
BLI_remlink(freestyle_modules, module_conf);
BLI_insertlink(freestyle_modules, module_conf->next, module_conf);
}
void FRS_set_module_path(void *module_index_ptr, void *unused)
{
StyleModuleConf* module_conf = (StyleModuleConf*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
freestyle_current_module_path = module_conf->module_path;
}
#ifdef __cplusplus
}

View File

@@ -1,8 +1,9 @@
#include "BlenderFileLoader.h"
BlenderFileLoader::BlenderFileLoader(Render *re)
BlenderFileLoader::BlenderFileLoader(Render *re, SceneRenderLayer* srl)
{
_re = re;
_srl = srl;
_Scene = NULL;
_numFacesRead = 0;
_minEdgeSize = DBL_MAX;
@@ -19,28 +20,13 @@ NodeGroup* BlenderFileLoader::Load()
ObjectRen *obr;
cout << "\n=== Importing triangular meshes into Blender ===" << endl;
SceneRenderLayer *srl, *active_srl = NULL;
int count = 0;
for(srl= (SceneRenderLayer *)_re->scene->r.layers.first; srl; srl= srl->next) {
if(srl->layflag & SCE_LAY_FRS) {
if (!active_srl) active_srl = srl;
count++;
}
}
if (count > 1) {
cout << "Warning: Freestyle is enabled in the following " << count << " scene render layers:" << endl;
for(srl= (SceneRenderLayer *)_re->scene->r.layers.first; srl; srl= srl->next)
if(srl->layflag & SCE_LAY_FRS)
cout << " \"" << srl->name << "\"" << ((active_srl == srl) ? " (only this is taken into account)" : "") << endl;
}
// creation of the scene root node
_Scene = new NodeGroup;
int id = 0;
for(obi= (ObjectInstanceRen *) _re->instancetable.first; obi; obi=obi->next) {
if (!(obi->lay & _re->scene->lay & active_srl->lay))
if (!(obi->lay & _re->scene->lay & _srl->lay))
continue;
obr= obi->obr;

View File

@@ -38,7 +38,7 @@ class LIB_SCENE_GRAPH_EXPORT BlenderFileLoader
{
public:
/*! Builds a MaxFileLoader */
BlenderFileLoader(Render *re);
BlenderFileLoader(Render *re, SceneRenderLayer* srl);
virtual ~BlenderFileLoader();
/*! Loads the 3D scene and returns a pointer to the scene root node */
@@ -55,6 +55,7 @@ protected:
protected:
Render* _re;
SceneRenderLayer* _srl;
NodeGroup* _Scene;
unsigned _numFacesRead;
real _minEdgeSize;

View File

@@ -228,20 +228,16 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const{
}
void BlenderStrokeRenderer::RenderScene( Render *re ) {
Render* BlenderStrokeRenderer::RenderScene( Render *re ) {
scene->r.mode &= ~( R_EDGE_FRS | R_SHADOW | R_SSS | R_PANORAMA | R_ENVMAP | R_MBLUR );
scene->r.scemode &= ~( R_SINGLE_LAYER );
scene->r.planes = R_PLANES32;
scene->r.imtype = R_PNG;
re->freestyle_render = RE_NewRender(scene->id.name);
Render* freestyle_render = RE_NewRender(scene->id.name);
RE_BlenderFrame( re->freestyle_render, scene, 1);
// char filepath[255];
// BLI_strncpy( filepath, "/Users/mx/Desktop/", sizeof(filepath) );
// strcat(filepath, "frs_result");
// BIF_save_rendered_image(filepath);
RE_BlenderFrame( freestyle_render, scene, 1);
return freestyle_render;
}
void BlenderStrokeRenderer::Close() {

View File

@@ -30,7 +30,7 @@ public:
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const;
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const;
void RenderScene(Render *re);
Render* RenderScene(Render *re);
void Close();
protected:

View File

@@ -171,6 +171,12 @@ void Canvas::Erase()
stroke_count = 0;
}
void Canvas::PushBackStyleModule(StyleModule *iStyleModule) {
StrokeLayer* layer = new StrokeLayer();
_StyleModules.push_back(iStyleModule);
_Layers.push_back(layer);
}
void Canvas::InsertStyleModule(unsigned index, StyleModule *iStyleModule) {
unsigned size = _StyleModules.size();
StrokeLayer* layer = new StrokeLayer();

View File

@@ -180,6 +180,7 @@ public:
/*! modifiers */
inline void setSelectedFEdge(FEdge *iFEdge) {_SelectedFEdge = iFEdge;}
/*! inserts a shader at pos index+1 */
void PushBackStyleModule(StyleModule *iStyleModule);
void InsertStyleModule(unsigned index, StyleModule *iStyleModule);
void RemoveStyleModule(unsigned index);
void SwapStyleModules(unsigned i1, unsigned i2);

View File

@@ -314,7 +314,6 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_FS_PIC 1601
#define B_FS_BACKBUF 1602
#define B_FS_FRS 1603
#define B_FS_FTYPE 1604 /* FTYPE is no more */
#define B_DORENDER 1605
#define B_DOANIM 1606
@@ -361,6 +360,10 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_ADD_FFMPEG_VIDEO_OPTION 1647
#define B_ADD_FFMPEG_AUDIO_OPTION 1648
#define B_FRS_SELECT_RENDER_LAYER 1649
#define B_FRS_ADD_MODULE 1650
#define B_FRS_SELECT_MODULE_FILE 1651
#define B_SEQ_BUT_PLUGIN 1691
#define B_SEQ_BUT_RELOAD 1692
#define B_SEQ_BUT_EFFECT 1693

View File

@@ -198,9 +198,6 @@ struct Render
ListBase *sss_points;
struct Material *sss_mat;
/* Freestyle */
struct Render* freestyle_render;
ListBase customdata_names;
struct Object *excludeob;

View File

@@ -4427,11 +4427,6 @@ void RE_Database_Free(Render *re)
free_occ(re);
free_strand_surface(re);
if( re->freestyle_render ) {
RE_FreeRender(re->freestyle_render);
re->freestyle_render = NULL;
}
re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
re->i.convertdone= 0;

View File

@@ -901,42 +901,6 @@ static void addps(ListBase *lb, intptr_t *rd, int obi, int facenr, int z, int ma
ps->shadfac= 0;
}
static void freestyle_enhance_add(RenderPart *pa, RenderLayer *rl)
{
RenderLayer *freestyle_rl;
RenderLayer *rlpp[RE_MAX_OSA];
int totsample;
int x, y, od;
float* freestyle;
if( R.freestyle_render == NULL || R.freestyle_render->result == NULL )
return;
freestyle_rl = render_get_active_layer( R.freestyle_render, R.freestyle_render->result );
if( freestyle_rl->rectf == NULL)
return;
totsample= get_sample_layers(pa, rl, rlpp);
od = 0;
for( y = pa->disprect.ymin; y < pa->disprect.ymax; y++) {
for( x = pa->disprect.xmin; x < pa->disprect.xmax; x++, od++) {
int sample;
if( x < 0 || y < 0 || x > R.rectx - 1 || y > R.recty - 1 )
continue;
freestyle = freestyle_rl->rectf + 4 * (R.rectx * y + x);
if( freestyle[3] > 0.0) {
for( sample = 0; sample < totsample; sample++) {
float *rgbrect = rlpp[sample]->rectf + 4*od;
addAlphaOverFloat(rgbrect, freestyle);
}
}
}
}
}
static void edge_enhance_add(RenderPart *pa, float *rectf, float *arect)
{
float addcol[4];
@@ -1254,10 +1218,6 @@ void zbufshadeDA_tile(RenderPart *pa)
if(rl->layflag & SCE_LAY_EDGE)
if(R.r.mode & R_EDGE)
edge_enhance_add(pa, rl->rectf, edgerect);
if(rl->layflag & SCE_LAY_FRS)
if(R.r.mode & R_EDGE_FRS)
freestyle_enhance_add(pa, rl);
if(rl->passflag & SCE_PASS_VECTOR)
reset_sky_speed(pa, rl);
@@ -1423,10 +1383,6 @@ void zbufshade_tile(RenderPart *pa)
edge_enhance_add(pa, rl->rectf, edgerect);
}
if(rl->layflag & SCE_LAY_FRS)
if(R.r.mode & R_EDGE_FRS)
freestyle_enhance_add(pa, rl);
if(rl->passflag & SCE_PASS_VECTOR)
reset_sky_speed(pa, rl);

View File

@@ -1358,6 +1358,12 @@ void do_sequencer_panels(unsigned short event)
/* ************************* SCENE *********************** */
static void freestyle_set_style_module_name(char *name)
{
strcpy(freestyle_current_module_path, name);
allqueue(REDRAWBUTSSCENE, 0);
BIF_undo_push("Change style module");
}
static void output_pic(char *name)
{
@@ -1380,15 +1386,6 @@ static void backbuf_pic(char *name)
BIF_undo_push("Change background picture");
}
static void freestyle_module(char *name)
{
strcpy(style_module, name);
allqueue(REDRAWBUTSSCENE, 0);
BIF_undo_push("Change style module");
}
static void run_playanim(char *file)
{
extern char bprogname[]; /* usiblender.c */
@@ -1488,14 +1485,7 @@ void do_render_panels(unsigned short event)
activate_imageselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
else
activate_fileselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
break;
case B_FS_FRS:
sa= closest_bigger_area();
areawinset(sa->win);
activate_fileselect(FILE_SPECIAL, "SELECT STYLE MODULE", style_module, freestyle_module);
break;
break;
case B_PR_PAL:
G.scene->r.xsch= 720;
@@ -1752,6 +1742,23 @@ void do_render_panels(unsigned short event)
allqueue(REDRAWBUTSSCENE, 0);
break;
#endif
case B_FRS_SELECT_RENDER_LAYER:
FRS_select_layer( BLI_findlink(&G.scene->r.layers, freestyle_current_layer_number ) );
allqueue(REDRAWBUTSSCENE, 0);
break;
case B_FRS_ADD_MODULE:
FRS_add_module();
allqueue(REDRAWBUTSSCENE, 0);
break;
case B_FRS_SELECT_MODULE_FILE:
sa= closest_bigger_area();
areawinset(sa->win);
activate_fileselect(FILE_SPECIAL, "SELECT STYLE MODULE", freestyle_current_module_path, freestyle_set_style_module_name);
break;
}
}
@@ -3297,25 +3304,80 @@ static void render_panel_yafrayGlobal()
#endif /* disable yafray stuff */
static void render_panel_freestyle()
{
{
uiBlock *block;
SceneRenderLayer *srl;
int len;
short a, nr;
char *str;
uiBut *bt;
int module_list_y;
StyleModuleConf* module_conf;
int module_number, last_module_number;
// initialization
FRS_initialize();
if( strlen(style_module) == 0 )
FRS_initialize();
block= uiNewBlock(&curarea->uiblocks, "render_panel_freestyle", UI_EMBOSS, UI_HELV, curarea->win);
// block
block = uiNewBlock(&curarea->uiblocks, "render_panel_freestyle", UI_EMBOSS, UI_HELV, curarea->win);
uiNewPanelTabbed("Render", "Render");
if(uiNewPanel(curarea, block, "Freestyle", "Render", 320, 0, 318, 204)==0) return;
// menu
len = 32 + 32*BLI_countlist(&G.scene->r.layers);
str = MEM_callocN(len, "menu layers");
a = strlen(str);
for(nr=0, srl= G.scene->r.layers.first; srl; srl= srl->next, nr++) {
a+= sprintf(str+a, "|%s %%i%d %%x%d", srl->name, ICON_BLANK1, nr);
}
uiDefBut(block, LABEL, 0, "Render Layer:", 10,210,100,20, NULL, 0, 0, 0, 0, "");
uiDefButS(block, MENU, B_FRS_SELECT_RENDER_LAYER, str, 110,210,200,20, &freestyle_current_layer_number, 0, 0, 0, 0, "Settings for current Render Layer");
MEM_freeN(str);
// label to force a boundbox for buttons not to be centered
uiBlockBeginAlign(block);
uiDefIconBut(block, BUT, B_FS_FRS, ICON_FILESEL, 10, 190, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get style module");
uiDefBut(block, TEX,0,"", 31, 190, 279, 20, style_module, 0.0,79.0, 0, 0, "Style module path name");
uiDefButF(block, NUM, B_NOP, "Sphere Radius", 10,170,300,20, &freestyle_sphere_radius, 0.0f, 100.0f, 10, 2, "Sphere radius (x mean edge size)");
uiDefButBitI(block, TOG, FREESTYLE_RIDGES_AND_VALLEYS_FLAG, B_NOP, "Ridges and Valleys", 10, 150, 150, 20, &freestyle_flags, 0, 0, 0, 0, "Compute ridges and valleys");
uiDefButBitI(block, TOG, FREESTYLE_SUGGESTIVE_CONTOURS_FLAG, B_NOP, "Suggestive Contours", 10, 130, 150, 20, &freestyle_flags, 0, 0, 0, 0, "Compute suggestive contours");
uiDefButF(block, NUM, B_NOP, "kr Derivative Epsilon", 10,110,300,20, &freestyle_dkr_epsilon, 0.0f, 10.0f, 0.1, 3, "Suggestive contour kr derivative epsilon");
uiDefButF(block, NUM, B_NOP, "Sphere Radius", 10,180,300,20, freestyle_sphere_radius, 0.0f, 100.0f, 10, 2, "Sphere radius (x mean edge size)");
uiDefButBitI(block, TOG, FREESTYLE_RIDGES_AND_VALLEYS_FLAG, B_NOP, "Ridges and Valleys", 10, 160, 150, 20, freestyle_flags, 0, 0, 0, 0, "Compute ridges and valleys");
uiDefButBitI(block, TOG, FREESTYLE_SUGGESTIVE_CONTOURS_FLAG, B_NOP, "Suggestive Contours", 10, 140, 150, 20, freestyle_flags, 0, 0, 0, 0, "Compute suggestive contours");
uiDefButF(block, NUM, B_NOP, "kr Derivative Epsilon", 10,120,300,20, freestyle_dkr_epsilon, 0.0f, 10.0f, 0.1, 3, "Suggestive contour kr derivative epsilon");
uiBlockEndAlign(block);
module_list_y = 90;
module_number = 0;
last_module_number = BLI_countlist( freestyle_modules ) - 1;
for( module_conf = freestyle_modules->first; module_conf; module_conf = module_conf->next, module_list_y -= 20, module_number++ )
{
uiDefIconButS(block, ICONTOG, B_NOP, ICON_CHECKBOX_HLT-1, 10, module_list_y, 20, 20, &(module_conf->is_displayed), 0.0, 0.0, 0, 0, "Disable or enable this style module");
bt = uiDefIconBut(block, BUT, B_FRS_SELECT_MODULE_FILE, ICON_FILESEL, 30, module_list_y, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get style module");
uiButSetFunc(bt, FRS_set_module_path, (void *)(intptr_t)module_number, NULL);
uiDefBut(block,TEX, 0, "", 50, module_list_y, 215, 20, module_conf->module_path, 0.0,79.0, 0, 0, "Style module path name");
bt = uiDefIconBut(block, BUT, B_REDR, VICON_X, 265, module_list_y, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Delete this style module");
uiButSetFunc(bt, FRS_delete_module, (void *)(intptr_t)module_number, NULL);
uiBlockSetEmboss(block, UI_EMBOSSN);
if( module_number != 0 ) {
bt = uiDefIconBut(block, BUT, B_REDR, VICON_MOVE_UP, 288, module_list_y + 2, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move this style module up");
uiButSetFunc(bt, FRS_move_up_module, (void *)(intptr_t)module_number, NULL);
}
if( module_number != last_module_number ) {
bt = uiDefIconBut(block, BUT, B_REDR, VICON_MOVE_DOWN, 304, module_list_y + 2, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move this style module down");
uiButSetFunc(bt, FRS_move_down_module, (void *)(intptr_t)module_number, NULL);
}
uiBlockSetCol(block, TH_AUTO);
uiBlockSetEmboss(block, UI_EMBOSS);
}
uiDefBut(block, BUT, B_FRS_ADD_MODULE, "Add style module", 10, module_list_y, 150, 20, 0, 0, 0, 0, 0, "Add new style module");
}
static void layer_copy_func(void *lay_v, void *lay_p)
@@ -3338,9 +3400,18 @@ static void delete_scene_layer_func(void *srl_v, void *act_i)
if(BLI_countlist(&G.scene->r.layers)>1) {
intptr_t act= (intptr_t)act_i;
int deleted_layer = G.scene->r.actlay;
FRS_delete_layer( BLI_findlink(&G.scene->r.layers, deleted_layer), 0 );
BLI_remlink(&G.scene->r.layers, srl_v);
MEM_freeN(srl_v);
G.scene->r.actlay= 0;
G.scene->r.actlay = 0;
if( deleted_layer == freestyle_current_layer_number ) {
FRS_select_layer( BLI_findlink(&G.scene->r.layers, G.scene->r.actlay) );
} else {
freestyle_current_layer_number = BLI_findindex(&G.scene->r.layers, freestyle_current_layer);
}
if(G.scene->nodetree) {
bNode *node;

View File

@@ -1175,6 +1175,8 @@ void exit_usiblender(void)
quicktime_exit();
#endif
FRS_exit();
/* undo free stuff */
undo_editmode_clear();
undo_imagepaint_clear();