[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26175] trunk/blender/source/blender: Added Hue and Value modes to Hue Correct node, alongside existing

Matt Ebb matt at mke3.net
Thu Jan 21 23:23:58 CET 2010


Revision: 26175
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26175
Author:   broken
Date:     2010-01-21 23:23:57 +0100 (Thu, 21 Jan 2010)

Log Message:
-----------
Added Hue and Value modes to Hue Correct node, alongside existing 
Saturation. Works the same way, selectively hue shifting or darkening/
brightening pixels based on their original hue.

Example:
http://mke3.net/blender/devel/2.5/hue_correct_hue_val.jpg

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_templates.c
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c	2010-01-21 22:20:49 UTC (rev 26174)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c	2010-01-21 22:23:57 UTC (rev 26175)
@@ -1851,6 +1851,24 @@
 			uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
 		}
 	}
+	else if (labeltype == 'h') {
+		/* HSV */
+		sub= uiLayoutRow(row, 1);
+		uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
+		
+		if(cumap->cm[0].curve) {
+			bt= uiDefButI(block, ROW, 0, "H", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
+			uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
+		}
+		if(cumap->cm[1].curve) {
+			bt= uiDefButI(block, ROW, 0, "S", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
+			uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
+		}
+		if(cumap->cm[2].curve) {
+			bt= uiDefButI(block, ROW, 0, "V", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
+			uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
+		}
+	}
 	else
 		uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
 	

Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c	2010-01-21 22:20:49 UTC (rev 26174)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c	2010-01-21 22:23:57 UTC (rev 26175)
@@ -46,13 +46,21 @@
 	
 	rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2);
 	
-	/* returns default 0.5 */
+	/* adjust hue, scaling returned default 0.5 up to 1 */
 	f = curvemapping_evaluateF(node->storage, 0, hsv[0]);
+	hsv[0] *= (f * 2.f);
 	
-	/* adjust saturation, scaling up to 1 */
+	/* adjust saturation, scaling returned default 0.5 up to 1 */
+	f = curvemapping_evaluateF(node->storage, 1, hsv[0]);
 	hsv[1] *= (f * 2.f);
 	
+	/* adjust value, scaling returned default 0.5 up to 1 */
+	f = curvemapping_evaluateF(node->storage, 2, hsv[0]);
+	hsv[2] *= (f * 2.f);
+	
+	CLAMP(hsv[0], 0.f, 1.f);
 	CLAMP(hsv[1], 0.f, 1.f);
+	CLAMP(hsv[2], 0.f, 1.f);
 	
 	/* convert back to rgb */
 	hsv_to_rgb(hsv[0], hsv[1], hsv[2], out, out+1, out+2);
@@ -67,13 +75,21 @@
 	
 	rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2);
 	
-	/* returns default 0.5 */
+	/* adjust hue, scaling returned default 0.5 up to 1 */
 	f = curvemapping_evaluateF(node->storage, 0, hsv[0]);
+	hsv[0] *= (f * 2.f);
 	
-	/* adjust saturation, scaling up to 1 */
+	/* adjust saturation, scaling returned default 0.5 up to 1 */
+	f = curvemapping_evaluateF(node->storage, 1, hsv[0]);
 	hsv[1] *= (f * 2.f);
 	
+	/* adjust value, scaling returned default 0.5 up to 1 */
+	f = curvemapping_evaluateF(node->storage, 2, hsv[0]);
+	hsv[2] *= (f * 2.f);
+	
+	CLAMP(hsv[0], 0.f, 1.f);
 	CLAMP(hsv[1], 0.f, 1.f);
+	CLAMP(hsv[2], 0.f, 1.f);
 	
 	/* convert back to rgb */
 	hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
@@ -121,26 +137,32 @@
 static void node_composit_init_huecorrect(bNode* node)
 {
 	CurveMapping *cumapping = node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
-	CurveMap *cuma = &cumapping->cm[0];
-	int i;
+	int c, i;
 	
-	/* set default horizontal curve */
-	if(cuma->curve)
-		MEM_freeN(cuma->curve);
-	
-	cuma->totpoint= 9;
-	cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points");
-	
-	for (i=0; i < cuma->totpoint; i++)
-	{
-		cuma->curve[i].x= i / ((float)cuma->totpoint-1);
-		cuma->curve[i].y= 0.5;
+	for (c=0; c<3; c++) {
+		CurveMap *cuma = &cumapping->cm[c];
+		
+		/* set default horizontal curve */
+		if(cuma->curve)
+			MEM_freeN(cuma->curve);
+		
+		cuma->totpoint= 9;
+		cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points");
+		
+		for (i=0; i < cuma->totpoint; i++)
+		{
+			cuma->curve[i].x= i / ((float)cuma->totpoint-1);
+			cuma->curve[i].y= 0.5;
+		}
+		
+		if(cuma->table) {
+			MEM_freeN(cuma->table);
+			cuma->table= NULL;
+		}
 	}
 	
-	if(cuma->table) {
-		MEM_freeN(cuma->table);
-		cuma->table= NULL;
-	}
+	/* default to showing Saturation */
+	cumapping->cur = 1;
 }
 
 bNodeType cmp_node_huecorrect= {





More information about the Bf-blender-cvs mailing list