[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12407] trunk/blender/source/blender: nodes from eechlo

Campbell Barton cbarton at metavr.com
Fri Oct 26 17:32:36 CEST 2007


Revision: 12407
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12407
Author:   campbellbarton
Date:     2007-10-26 17:32:36 +0200 (Fri, 26 Oct 2007)

Log Message:
-----------
nodes from eechlo
* glare
* tonemap
* lense distort
* fast gauss blur

http://projects.blender.org/tracker/?func=detail&atid=127&aid=7505&group_id=9

made fast gauss blur an option for the blur node rather then a separate node.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_node.h
    trunk/blender/source/blender/blenkernel/intern/node.c
    trunk/blender/source/blender/imbuf/intern/radiance_hdr.c
    trunk/blender/source/blender/makesdna/DNA_node_types.h
    trunk/blender/source/blender/makesdna/DNA_scene_types.h
    trunk/blender/source/blender/nodes/CMP_node.h
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_blur.c
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c
    trunk/blender/source/blender/nodes/intern/CMP_util.c
    trunk/blender/source/blender/nodes/intern/CMP_util.h
    trunk/blender/source/blender/src/drawnode.c

Added Paths:
-----------
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_glare.c
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_lensdist.c
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_tonemap.c

Modified: trunk/blender/source/blender/blenkernel/BKE_node.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_node.h	2007-10-26 15:13:50 UTC (rev 12406)
+++ trunk/blender/source/blender/blenkernel/BKE_node.h	2007-10-26 15:32:36 UTC (rev 12407)
@@ -303,6 +303,10 @@
 #define CMP_NODE_INVERT		251
 #define CMP_NODE_NORMALIZE      252
 
+#define CMP_NODE_GLARE		301
+#define CMP_NODE_TONEMAP	302
+#define CMP_NODE_LENSDIST	303
+
 /* channel toggles */
 #define CMP_CHAN_RGB		1
 #define CMP_CHAN_A			2

Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c	2007-10-26 15:13:50 UTC (rev 12406)
+++ trunk/blender/source/blender/blenkernel/intern/node.c	2007-10-26 15:32:36 UTC (rev 12407)
@@ -2365,6 +2365,10 @@
 	nodeRegisterType(ntypelist, &cmp_node_flip);
 	nodeRegisterType(ntypelist, &cmp_node_displace);
 	nodeRegisterType(ntypelist, &cmp_node_mapuv);
+
+	nodeRegisterType(ntypelist, &cmp_node_glare);
+	nodeRegisterType(ntypelist, &cmp_node_tonemap);
+	nodeRegisterType(ntypelist, &cmp_node_lensdist);
 }
 
 static void registerShaderNodes(ListBase *ntypelist) 

Modified: trunk/blender/source/blender/imbuf/intern/radiance_hdr.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/radiance_hdr.c	2007-10-26 15:13:50 UTC (rev 12406)
+++ trunk/blender/source/blender/imbuf/intern/radiance_hdr.c	2007-10-26 15:32:36 UTC (rev 12407)
@@ -161,8 +161,10 @@
 
 int imb_is_a_hdr(void *buf)
 {
-	/* For recognition, Blender only loades first 32 bytes, so use #?RADIANCE id instead */
-	if (strstr((char*)buf, "#?RADIANCE")) return 1;
+	// For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead
+	// update: actually, the 'RADIANCE' part is just an optional program name, the magic word is really only the '#?' part
+	//if (strstr((char*)buf, "#?RADIANCE")) return 1;
+	if (strstr((char*)buf, "#?")) return 1;
 	// if (strstr((char*)buf, "32-bit_rle_rgbe")) return 1;
 	return 0;
 }
@@ -176,7 +178,6 @@
 	int found=0;
 	int width=0, height=0;
 	int x, y;
-	int ir, ig, ib;
 	unsigned char* ptr;
 	unsigned char* rect;
 	char oriY[80], oriX[80];
@@ -225,18 +226,14 @@
 					*rect_float++ = fcol[GRN];
 					*rect_float++ = fcol[BLU];
 					*rect_float++ = 1.0f;
-
 					/* Also old oldstyle for the rest of blender which is not using floats yet */
-/* very weird mapping! (ton) */
-					fcol[RED] = 1.f-exp(fcol[RED]*-1.414213562f);
-					fcol[GRN] = 1.f-exp(fcol[GRN]*-1.414213562f);
-					fcol[BLU] = 1.f-exp(fcol[BLU]*-1.414213562f);
-					ir = (int)(255.f*pow(fcol[RED], 0.45454545f));
-					ig = (int)(255.f*pow(fcol[GRN], 0.45454545f));
-					ib = (int)(255.f*pow(fcol[BLU], 0.45454545f));
-					*rect++ = (unsigned char)((ir<0) ? 0 : ((ir>255) ? 255 : ir));
-					*rect++ = (unsigned char)((ig<0) ? 0 : ((ig>255) ? 255 : ig));
-					*rect++ = (unsigned char)((ib<0) ? 0 : ((ib>255) ? 255 : ib));
+					// e: changed to simpler tonemapping, previous code was rather slow (is this actually still relevant at all?)
+					fcol[RED] = fcol[RED]/(1.f + fcol[RED]);
+					fcol[GRN] = fcol[GRN]/(1.f + fcol[GRN]);
+					fcol[BLU] = fcol[BLU]/(1.f + fcol[BLU]);
+					*rect++ = (unsigned char)((fcol[RED] < 0.f) ? 0 : ((fcol[RED] > 1.f) ? 255 : (255.f*fcol[RED])));
+					*rect++ = (unsigned char)((fcol[GRN] < 0.f) ? 0 : ((fcol[GRN] > 1.f) ? 255 : (255.f*fcol[GRN])));
+					*rect++ = (unsigned char)((fcol[BLU] < 0.f) ? 0 : ((fcol[BLU] > 1.f) ? 255 : (255.f*fcol[BLU])));
 					*rect++ = 255;
 				}
 			}
@@ -328,11 +325,11 @@
 	fputc(10, file);
 	fprintf(file, "# %s", "Created with Blender");
 	fputc(10, file);
-	fprintf(file, "FORMAT=32-bit_rle_rgbe");
-	fputc(10, file);
 	fprintf(file, "EXPOSURE=%25.13f", 1.0);
 	fputc(10, file);
+	fprintf(file, "FORMAT=32-bit_rle_rgbe");
 	fputc(10, file);
+	fputc(10, file);
 	fprintf(file, "-Y %d +X %d", height, width);
 	fputc(10, file);
 }

Modified: trunk/blender/source/blender/makesdna/DNA_node_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_node_types.h	2007-10-26 15:13:50 UTC (rev 12406)
+++ trunk/blender/source/blender/makesdna/DNA_node_types.h	2007-10-26 15:32:36 UTC (rev 12407)
@@ -230,4 +230,24 @@
 	float fstop, maxblur, bthresh, scale;
 } NodeDefocus;
 
+
+/* qdn: glare node */
+typedef struct NodeGlare {
+	char quality, type, iter;
+	char angle, angle_ofs, size, pad[2];
+	float colmod, mix, threshold, fade;
+} NodeGlare;
+
+/* qdn: tonemap node */
+typedef struct NodeTonemap {
+	float key, offset, gamma;
+	float f, m, a, c;
+	int type;
+} NodeTonemap;
+
+/* qdn: lens distortion node */
+typedef struct NodeLensDist {
+	short jit, proj, fit, pad;
+} NodeLensDist;
+
 #endif

Modified: trunk/blender/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_scene_types.h	2007-10-26 15:13:50 UTC (rev 12406)
+++ trunk/blender/source/blender/makesdna/DNA_scene_types.h	2007-10-26 15:32:36 UTC (rev 12407)
@@ -507,6 +507,7 @@
 #define R_FILTER_CATROM	4
 #define R_FILTER_GAUSS	5
 #define R_FILTER_MITCH	6
+#define R_FILTER_FAST_GAUSS	7 /* note, this is only used for nodes at the moment */
 
 /* yafray: renderer flag (not only exclusive to yafray) */
 #define R_INTERN	0

Modified: trunk/blender/source/blender/nodes/CMP_node.h
===================================================================
--- trunk/blender/source/blender/nodes/CMP_node.h	2007-10-26 15:13:50 UTC (rev 12406)
+++ trunk/blender/source/blender/nodes/CMP_node.h	2007-10-26 15:32:36 UTC (rev 12407)
@@ -97,6 +97,8 @@
 extern bNodeType cmp_node_displace;
 extern bNodeType cmp_node_mapuv;
 
+extern bNodeType cmp_node_glare;
+extern bNodeType cmp_node_tonemap;
+extern bNodeType cmp_node_lensdist;
+
 #endif
-
-

Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_blur.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_blur.c	2007-10-26 15:13:50 UTC (rev 12406)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_blur.c	2007-10-26 15:32:36 UTC (rev 12407)
@@ -28,9 +28,8 @@
  */
 
 #include "../CMP_util.h"
+#include "qdutil.h" /* use for fast gauss only */
 
-
-
 /* **************** BLUR ******************** */
 static bNodeSocketType cmp_node_blur_in[]= {
 	{	SOCK_RGBA, 1, "Image",			0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
@@ -555,8 +554,6 @@
 		free_compbuf(ref_use);
 }
 
-
-
 static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 {
 	CompBuf *new, *img= in[0]->data;
@@ -564,35 +561,48 @@
 	if(img==NULL || out[0]->hasoutput==0)
 		return;
 	
-	if(img->type==CB_VEC2 || img->type==CB_VEC3) {
-		img= typecheck_compbuf(in[0]->data, CB_RGBA);
-	}
+	if (((NodeBlurData *)node->storage)->filtertype == R_FILTER_FAST_GAUSS) {
+		CompBuf *new, *img = in[0]->data;
+		/*from eeshlo's original patch, removed to fit in with the existing blur node */
+		/*const float sx = in[1]->vec[0], sy = in[2]->vec[0];*/
 	
-	/* if fac input, we do it different */
-	if(in[1]->data) {
+		NodeBlurData *nbd= node->storage;
+		const float sx = ((float)nbd->sizex)/2.0f, sy = ((float)nbd->sizey)/2.0f;
+		int c;
+
+		if ((img==NULL) || (out[0]->hasoutput==0)) return;
+
+		if (img->type == CB_VEC2)
+			new = typecheck_compbuf(img, CB_VAL);
+		else if (img->type == CB_VEC3)
+			new = typecheck_compbuf(img, CB_RGBA);
+		else
+			new = dupalloc_compbuf(img);
+
+		if ((sx == sy) && (sx > 0.f)) {
+			for (c=0; c<new->type; ++c)
+				IIR_gauss(new, sx, c, 3);
+		}
+		else {
+			if (sx > 0.f) {
+				for (c=0; c<new->type; ++c)
+					IIR_gauss(new, sx, c, 1);
+			}
+			if (sy > 0.f) {
+				for (c=0; c<new->type; ++c)
+					IIR_gauss(new, sy, c, 2);
+			}
+		}
+		out[0]->data = new;
 		
-		/* make output size of input image */
-		new= alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
-		
-		/* accept image offsets from other nodes */
-		new->xof = img->xof;
-		new->yof = img->yof;
-		
-		blur_with_reference(node, new, img, in[1]->data);
-		if(node->exec & NODE_BREAK) {
-			free_compbuf(new);
-			new= NULL;
+	} else { 
+		/* All non fast gauss blur methods */
+		if(img->type==CB_VEC2 || img->type==CB_VEC3) {
+			img= typecheck_compbuf(in[0]->data, CB_RGBA);
 		}
-		out[0]->data= new;
-	}
-	else {
 		
-		if(in[1]->vec[0]<=0.001f) {	/* time node inputs can be a tiny value */
-			new= pass_on_compbuf(img);
-		}
-		else {
-			NodeBlurData *nbd= node->storage;
-			CompBuf *gammabuf;
+		/* if fac input, we do it different */
+		if(in[1]->data) {
 			
 			/* make output size of input image */
 			new= alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
@@ -600,33 +610,57 @@
 			/* accept image offsets from other nodes */
 			new->xof = img->xof;
 			new->yof = img->yof;
-				
-			if(nbd->gamma) {
-				gammabuf= dupalloc_compbuf(img);
-				gamma_correct_compbuf(gammabuf, 0);
-			}
-			else gammabuf= img;
 			
-			if(nbd->bokeh)
-				bokeh_single_image(node, new, gammabuf, in[1]->vec[0]);
-			else if(1)
-				blur_single_image(node, new, gammabuf, in[1]->vec[0]);
-			else	/* bloom experimental... */
-				bloom_with_reference(new, gammabuf, NULL, in[1]->vec[0], nbd);
-			
-			if(nbd->gamma) {
-				gamma_correct_compbuf(new, 1);
-				free_compbuf(gammabuf);
-			}
+			blur_with_reference(node, new, img, in[1]->data);
 			if(node->exec & NODE_BREAK) {
 				free_compbuf(new);
 				new= NULL;
 			}
+			out[0]->data= new;
 		}
-		out[0]->data= new;
+		else {
+			
+			if(in[1]->vec[0]<=0.001f) {	/* time node inputs can be a tiny value */
+				new= pass_on_compbuf(img);
+			}
+			else {
+				NodeBlurData *nbd= node->storage;
+				CompBuf *gammabuf;
+				
+				/* make output size of input image */
+				new= alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
+				
+				/* accept image offsets from other nodes */
+				new->xof = img->xof;
+				new->yof = img->yof;
+					
+				if(nbd->gamma) {
+					gammabuf= dupalloc_compbuf(img);
+					gamma_correct_compbuf(gammabuf, 0);
+				}
+				else gammabuf= img;
+				
+				if(nbd->bokeh)
+					bokeh_single_image(node, new, gammabuf, in[1]->vec[0]);
+				else if(1)
+					blur_single_image(node, new, gammabuf, in[1]->vec[0]);
+				else	/* bloom experimental... */
+					bloom_with_reference(new, gammabuf, NULL, in[1]->vec[0], nbd);
+				

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list