[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30915] trunk/blender/source/blender/nodes /intern/CMP_nodes/CMP_colorbalance.c: Change compositor color balance to match the sequencer exactly, for this to work linear/ srgb conversions need to be done which that nice since it has to convert from /to the color spaces each time, after quite a lot of testing I think its the best way to go.

Campbell Barton ideasman42 at gmail.com
Sat Jul 31 01:32:49 CEST 2010


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

Log Message:
-----------
Change compositor color balance to match the sequencer exactly, for this to work linear/srgb conversions need to be done which that nice since it has to convert from/to the color spaces each time, after quite a lot of testing I think its the best way to go.

The problem was that typical lift values  (0.5 - 1.5, in our case ) would over saturate shadows so that even minor adjustments would give unusable results.
tweaking the input lift to compensate for this helped with the shadows but would loose the color adjustments for the mid-tones.

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

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-30 23:25:26 UTC (rev 30914)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c	2010-07-30 23:32:49 UTC (rev 30915)
@@ -56,13 +56,17 @@
 
 /* note: lift_lgg is just 2-lift */
 DO_INLINE float colorbalance_lgg(float in, float lift_lgg, float gamma, float gain)
-{	
-	float x= (((in - 1.0f) * lift_lgg) + 1.0f) * 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
+	 * without lin/srgb conversions gives bad results (over-saturated shadows) with colors
+	 * slightly below 1.0. some correction can be done but it ends up looking bad for shadows or lighter tones - campbell */
+	float x= (((linearrgb_to_srgb(in) - 1.0f) * lift_lgg) + 1.0f) * gain;
 
 	/* prevent NaN */
 	if (x < 0.f) x = 0.f;
-	
-	return powf(x, (1.f/gamma));
+
+	return powf(srgb_to_linearrgb(x), gamma);
 }
 
 static void do_colorbalance_cdl(bNode *node, float* out, float *in)
@@ -125,15 +129,8 @@
 		NodeColorBalance *n= (NodeColorBalance *)node->storage;
 		int c;
 
-		copy_v3_v3(n->lift_lgg, n->lift);
-
 		for (c = 0; c < 3; c++) {
-			/* tweak to give more subtle results
-			 * values above 1.0 are scaled */
-			if(n->lift_lgg[c] > 1.0f)
-				n->lift_lgg[c] = pow(n->lift_lgg[c] - 1.0f, 2.0f) + 1.0f;
-
-			n->lift_lgg[c] = 2.0f - n->lift_lgg[c];
+			n->lift_lgg[c] = 2.0f - n->lift[c];
 		}
 	}
 





More information about the Bf-blender-cvs mailing list