[Bf-blender-cvs] [b8c9df6f215] blender2.8: Compositor: Added Weighted Standard Curve evaluation

Jeroen Bakker noreply at git.blender.org
Fri Aug 24 10:06:17 CEST 2018


Commit: b8c9df6f21587014cb6f11aa5bed6f9c1044e6ee
Author: Jeroen Bakker
Date:   Fri Aug 24 10:04:33 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBb8c9df6f21587014cb6f11aa5bed6f9c1044e6ee

Compositor: Added Weighted Standard Curve evaluation

Available in RGB Curve node in the compositor and as modifier in the
sequencer. I reshuffled the values of the enum. But a the first commit
is just 1 day old I think that the order is more important than the file
compatibility.

===================================================================

M	source/blender/blenkernel/intern/colortools.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/makesdna/DNA_color_types.h
M	source/blender/makesrna/intern/rna_color.c

===================================================================

diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index c934adc8762..0684231480b 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -953,6 +953,28 @@ static void curvemapping_evaluateRGBF_filmlike(const CurveMapping *cumap, float
 	vecout[channel_offset[1]] = v1;
 	vecout[channel_offset[2]] = v2;
 }
+
+static float curvemapping_weighted_standard_triangle(float a, float b, float a1)
+{
+	if (a != b)
+	{
+		float b1;
+		float a2 = a1 - a;
+
+		if (b < a)
+		{
+				b1 = b + a2 *      b  /     a ;
+		}
+		else {
+				b1 = b + a2 * (65535.f - b) / (65535.f - a);
+		}
+
+		return b1;
+	}
+
+	return a1;
+}
+
 /** same as #curvemapping_evaluate_premulRGBF
  * but black/bwmul are passed as args for the compositor
  * where they can change per pixel.
@@ -970,7 +992,8 @@ void curvemapping_evaluate_premulRGBF_ex(
 	const float g = (vecin[1] - black[1]) * bwmul[1];
 	const float b = (vecin[2] - black[2]) * bwmul[2];
 
-	switch (cumap->tone) {
+	switch (cumap->tone)
+	{
 		default:
 		case CURVE_TONE_STANDARD:
 		{
@@ -979,6 +1002,25 @@ void curvemapping_evaluate_premulRGBF_ex(
 			vecout[2] = curvemap_evaluateF(&cumap->cm[2], b);
 			break;
 		}
+		case CURVE_TONE_WEIGHTED_STANDARD:
+		{
+			float r1 = curvemap_evaluateF(&cumap->cm[0], r);
+			float g1 = curvemapping_weighted_standard_triangle(r, r1, g);
+			float b1 = curvemapping_weighted_standard_triangle(r, r1, b);
+
+			float g2 = curvemap_evaluateF(&cumap->cm[1], g);
+			float r2 = curvemapping_weighted_standard_triangle(g, g2, r);
+			float b2 = curvemapping_weighted_standard_triangle(g, g2, b);
+
+			float b3 = curvemap_evaluateF(&cumap->cm[2], b);
+			float r3 = curvemapping_weighted_standard_triangle(b, b3, r);
+			float g3 = curvemapping_weighted_standard_triangle(b, b3, g);
+
+			vecout[0] = r1 * 0.50f + r2 * 0.25f + r3 * 0.25f;
+			vecout[1] = g1 * 0.25f + g2 * 0.50f + g3 * 0.25f;
+			vecout[2] = b1 * 0.25f + b2 * 0.25f + b3 * 0.50f;
+			break;
+		}
 		case CURVE_TONE_FILMLIKE:
 		{
 			if (r >= g) {
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 9c4e7faa73e..27805f2cf1e 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -2965,7 +2965,7 @@ static void curvemap_buttons_layout(
 
 	if (tone) {
 		split = uiLayoutSplit(layout, 0.0f, false);
-		uiItemR(uiLayoutRow(split, false), ptr, "tone", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+		uiItemR(uiLayoutRow(split, false), ptr, "tone", 0, NULL, ICON_NONE);
 	}
 
 	/* curve chooser */
diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h
index fe158f85cd9..def1a2bad91 100644
--- a/source/blender/makesdna/DNA_color_types.h
+++ b/source/blender/makesdna/DNA_color_types.h
@@ -107,8 +107,9 @@ typedef enum eCurveMappingPreset {
 
 /* CurveMapping->tone */
 typedef enum eCurveMappingTone {
-	CURVE_TONE_STANDARD = 0,
-	CURVE_TONE_FILMLIKE = 1,
+	CURVE_TONE_STANDARD =          0,
+	CURVE_TONE_WEIGHTED_STANDARD = 1,
+	CURVE_TONE_FILMLIKE =          2,
 } eCurveMappingTone;
 
 /* histogram->mode */
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 4cbe365167c..f91be9ae1e9 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -764,8 +764,9 @@ static void rna_def_curvemapping(BlenderRNA *brna)
 	FunctionRNA *func;
 
 	static const EnumPropertyItem tone_items[] = {
-		{CURVE_TONE_STANDARD, "STANDARD", 0, "Standard",  ""},
-		{CURVE_TONE_FILMLIKE, "FILMLIKE", 0, "Film like", ""},
+		{CURVE_TONE_STANDARD,          "STANDARD", 0, "Standard",          ""},
+		{CURVE_TONE_WEIGHTED_STANDARD, "WEIGHTED", 0, "Weighted Standard", ""},
+		{CURVE_TONE_FILMLIKE,          "FILMLIKE", 0, "Film like",         ""},
 		{0, NULL, 0, NULL, NULL}
 	};



More information about the Bf-blender-cvs mailing list