[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31637] trunk/blender/source/blender/nodes /intern/CMP_nodes/CMP_colorbalance.c: Tweaks to ASC-CDL colour balance formula to exactly match the spec.

Matt Ebb matt at mke3.net
Sun Aug 29 06:48:01 CEST 2010


Revision: 31637
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31637
Author:   broken
Date:     2010-08-29 06:48:00 +0200 (Sun, 29 Aug 2010)

Log Message:
-----------
Tweaks to ASC-CDL colour balance formula to exactly match the spec.

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-08-28 20:56:54 UTC (rev 31636)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c	2010-08-29 04:48:00 UTC (rev 31637)
@@ -43,15 +43,24 @@
 	{-1,0,""}
 };
 
+/* this function implements ASC-CDL according to the spec at http://www.asctech.org/
+ Slope
+       S = in * slope
+ Offset
+       O = S + offset 
+         = (in * slope) + offset
+ Power
+     out = Clamp(O) ^ power
+         = Clamp((in * slope) + offset) ^ power
+ */
 DO_INLINE float colorbalance_cdl(float in, float offset, float power, float slope)
 {
 	float x = in * slope + offset;
 	
 	/* prevent NaN */
-	if (x < 0.f) x = 0.f;
+	CLAMP(x, 0.0, 1.0);
 	
-	//powf(in * slope + offset, power)
-	return powf(x, 1.f/power);
+	return powf(x, power);
 }
 
 /* note: lift_lgg is just 2-lift, gamma_inv is 1.0/gamma */





More information about the Bf-blender-cvs mailing list