[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19357] branches/soc-2008-mxcurioni/source /blender: Freestyle was changed from a tile-based process to a post-processing effect .

Maxime Curioni maxime.curioni at gmail.com
Sun Mar 22 17:25:14 CET 2009


Revision: 19357
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19357
Author:   mxcurioni
Date:     2009-03-22 17:25:14 +0100 (Sun, 22 Mar 2009)

Log Message:
-----------
Freestyle was changed from a tile-based process to a post-processing effect. This will allow style modules to process the underlying color buffer ( AppCanvas::readColorPixels ) and depth buffer ( AppCanvas::readDepthPixels ), as was supported in the original program.
	
Corrected crash when Freestyle is rendered in "Single" render layer mode (for example, in the compositor)

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.cpp
    branches/soc-2008-mxcurioni/source/blender/render/intern/source/convertblender.c
    branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2009-03-22 15:30:43 UTC (rev 19356)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2009-03-22 16:25:14 UTC (rev 19357)
@@ -22,7 +22,9 @@
 	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);
+	
 #ifdef __cplusplus
 }
 #endif

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp	2009-03-22 15:30:43 UTC (rev 19356)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp	2009-03-22 16:25:14 UTC (rev 19357)
@@ -16,6 +16,7 @@
 
 #include "render_types.h"
 #include "renderpipeline.h"
+#include "pixelblending.h"
 
 #include "BLI_blenlib.h"
 #include "BIF_renderwin.h"
@@ -161,8 +162,58 @@
 			cout << "Freestyle cannot be used because the view map is not available" << endl;
 		}
 		cout << "\n###################################################################" << endl;
-	}	
+	}
 	
+	void FRS_composite_result(Render* re, SceneRenderLayer* srl)
+	{
+
+		RenderLayer *rl;
+	    float *src, *dest, *pixSrc, *pixDest;
+		int x, y, rectx, recty;
+		
+		if( re->freestyle_render == NULL || re->freestyle_render->result == NULL )
+			return;
+
+		rl = render_get_active_layer( re->freestyle_render, re->freestyle_render->result );
+	    if( !rl || rl->rectf == NULL) { cout << "Cannot find Freestyle result image" << endl; return; }
+		src  = rl->rectf;
+		
+		rl = RE_GetRenderLayer(re->result, srl->name);
+	    if( !rl || rl->rectf == NULL) { cout << "No layer to composite to" << endl; return; }
+		dest  = rl->rectf;
+		
+		rectx = re->rectx;
+		recty = re->recty;
+
+	    for( y = 0; y < recty; y++) {
+	        for( x = 0; x < rectx; x++) {
+
+	            pixSrc = src + 4 * (rectx * y + x);
+	            if( pixSrc[3] > 0.0) {
+					pixDest = dest + 4 * (rectx * y + x);
+					addAlphaOverFloat(pixDest, pixSrc);
+	             }
+	         }
+	    }
+		
+	}
+	
+	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;
+			}
+		}
+		
+		if( freestyle_srl ) {
+			FRS_prepare(re);
+			FRS_render_Blender(re);
+			FRS_composite_result(re, freestyle_srl);
+		}
+	}
+	
 #ifdef __cplusplus
 }
 #endif

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.cpp	2009-03-22 15:30:43 UTC (rev 19356)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.cpp	2009-03-22 16:25:14 UTC (rev 19357)
@@ -230,10 +230,12 @@
 
 void 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);
+	
 	RE_BlenderFrame( re->freestyle_render, scene, 1);
 
 	// char filepath[255];

Modified: branches/soc-2008-mxcurioni/source/blender/render/intern/source/convertblender.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/render/intern/source/convertblender.c	2009-03-22 15:30:43 UTC (rev 19356)
+++ branches/soc-2008-mxcurioni/source/blender/render/intern/source/convertblender.c	2009-03-22 16:25:14 UTC (rev 19357)
@@ -4879,13 +4879,7 @@
 		if((re->r.mode & R_SSS) && !re->test_break())
 			if(re->r.renderer==R_INTERN)
 				make_sss_tree(re);
-				
-		/* Freestyle */
-		if((re->r.mode & R_EDGE_FRS ) && !re->test_break())
-			if(re->r.renderer==R_INTERN) {	
-				FRS_prepare(re);
-				FRS_render_Blender(re);
-		}
+
 	}
 	
 	if(re->test_break())

Modified: branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c	2009-03-22 15:30:43 UTC (rev 19356)
+++ branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c	2009-03-22 16:25:14 UTC (rev 19357)
@@ -1637,6 +1637,10 @@
 		if(!re->test_break())
 			add_halo_flare(re);
 	
+	/* Freestyle  */
+	if( re->r.mode & R_EDGE_FRS && re->r.renderer==R_INTERN)
+		FRS_add_Freestyle(re);
+	
 	/* free all render verts etc */
 	RE_Database_Free(re);
 }





More information about the Bf-blender-cvs mailing list