[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30922] trunk/blender/source/blender: recent commit to make color balance work like the sequencer, I forgot that the gamma was inverted.

Campbell Barton ideasman42 at gmail.com
Sat Jul 31 12:03:09 CEST 2010


Revision: 30922
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30922
Author:   campbellbarton
Date:     2010-07-31 12:03:08 +0200 (Sat, 31 Jul 2010)

Log Message:
-----------
recent commit to make color balance work like the sequencer, I forgot that the gamma was inverted. fixed.

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_node_types.h
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c

Modified: trunk/blender/source/blender/makesdna/DNA_node_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_node_types.h	2010-07-31 10:03:08 UTC (rev 30921)
+++ trunk/blender/source/blender/makesdna/DNA_node_types.h	2010-07-31 10:03:08 UTC (rev 30922)
@@ -314,6 +314,7 @@
 
 	/* temp storage for inverted lift */
 	float lift_lgg[3];
+	float gamma_inv[3];
 } NodeColorBalance;
 
 typedef struct NodeColorspill {

Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c	2010-07-31 10:03:08 UTC (rev 30921)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c	2010-07-31 10:03:08 UTC (rev 30922)
@@ -54,8 +54,8 @@
 	return powf(x, 1.f/power);
 }
 
-/* note: lift_lgg is just 2-lift */
-DO_INLINE float colorbalance_lgg(float in, float lift_lgg, float gamma, float gain)
+/* note: lift_lgg is just 2-lift, gamma_inv is 1.0/gamma */
+DO_INLINE float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float gain)
 {
 	/* 1:1 match with the sequencer with linear/srgb conversions, the conversion isnt pretty
 	 * but best keep it this way, sice testing for durian shows a similar calculation
@@ -66,7 +66,7 @@
 	/* prevent NaN */
 	if (x < 0.f) x = 0.f;
 
-	return powf(srgb_to_linearrgb(x), gamma);
+	return powf(srgb_to_linearrgb(x), gamma_inv);
 }
 
 static void do_colorbalance_cdl(bNode *node, float* out, float *in)
@@ -94,9 +94,9 @@
 {
 	NodeColorBalance *n= (NodeColorBalance *)node->storage;
 
-	out[0] = colorbalance_lgg(in[0], n->lift_lgg[0], n->gamma[0], n->gain[0]);
-	out[1] = colorbalance_lgg(in[1], n->lift_lgg[1], n->gamma[1], n->gain[1]);
-	out[2] = colorbalance_lgg(in[2], n->lift_lgg[2], n->gamma[2], n->gain[2]);
+	out[0] = colorbalance_lgg(in[0], n->lift_lgg[0], n->gamma_inv[0], n->gain[0]);
+	out[1] = colorbalance_lgg(in[1], n->lift_lgg[1], n->gamma_inv[1], n->gain[1]);
+	out[2] = colorbalance_lgg(in[2], n->lift_lgg[2], n->gamma_inv[2], n->gain[2]);
 	out[3] = in[3];
 }
 
@@ -105,9 +105,9 @@
 	NodeColorBalance *n= (NodeColorBalance *)node->storage;
 	const float mfac= 1.0f - *fac;
 
-	out[0] = mfac*in[0] + *fac * colorbalance_lgg(in[0], n->lift_lgg[0], n->gamma[0], n->gain[0]);
-	out[1] = mfac*in[1] + *fac * colorbalance_lgg(in[1], n->lift_lgg[1], n->gamma[1], n->gain[1]);
-	out[2] = mfac*in[2] + *fac * colorbalance_lgg(in[2], n->lift_lgg[2], n->gamma[2], n->gain[2]);
+	out[0] = mfac*in[0] + *fac * colorbalance_lgg(in[0], n->lift_lgg[0], n->gamma_inv[0], n->gain[0]);
+	out[1] = mfac*in[1] + *fac * colorbalance_lgg(in[1], n->lift_lgg[1], n->gamma_inv[1], n->gain[1]);
+	out[2] = mfac*in[2] + *fac * colorbalance_lgg(in[2], n->lift_lgg[2], n->gamma_inv[2], n->gain[2]);
 	out[3] = in[3];
 }
 
@@ -131,6 +131,7 @@
 
 		for (c = 0; c < 3; c++) {
 			n->lift_lgg[c] = 2.0f - n->lift[c];
+			n->gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f/n->gamma[c] : 1000000.0f;
 		}
 	}
 





More information about the Bf-blender-cvs mailing list