[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31800] trunk/blender/source/blender/nodes /intern/CMP_nodes/CMP_levels.c: patch [#23703] Fix for Level compositing node; correct color representation

Campbell Barton ideasman42 at gmail.com
Tue Sep 7 04:36:53 CEST 2010


Revision: 31800
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31800
Author:   campbellbarton
Date:     2010-09-07 04:36:51 +0200 (Tue, 07 Sep 2010)

Log Message:
-----------
patch [#23703] Fix for Level compositing node; correct color representation
from Alexander Kuznetsov (alexk) 

--- copied from the tracker
Every image inside Blender is in linear color space and gets converted to SRGB upon saving.
Level node analyzed the linear image, which was not the one user saw because other output nodes converted image  to
sRGB.
This fix analyzes the image that user see (converting it to correct color space).
Here is difference:
http://www.pasteall.org/pic/show.php?id=5559

First histogram (before the fix) tells that image is underexposed, which is not the case.

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

Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_levels.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_levels.c	2010-09-07 02:10:51 UTC (rev 31799)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_levels.c	2010-09-07 02:36:51 UTC (rev 31800)
@@ -47,7 +47,7 @@
 	*out= r*0.35f + g*0.45f + b*0.2f;
 }
 
-static void fill_bins(bNode* node, CompBuf* in, int* bins)
+static void fill_bins(bNode* node, CompBuf* in, int* bins, int colorcor)
 {
 	float value[4];
 	int ivalue=0;
@@ -63,29 +63,39 @@
 			if(value[3] > 0.0) { /* don't count transparent pixels */
 				switch(node->custom1) {
 					case 1: { /* all colors */
+						if(colorcor)
+							linearrgb_to_srgb_v3_v3(&value[0],&value[0]);
 						rgb_tobw(value[0],value[1],value[2], &value[0]);
 						value[0]=value[0]*255; /* scale to 0-255 range */
 						ivalue=(int)value[0];
 						break;
 					}
 					case 2: { /* red channel */
+						if(colorcor)
+							value[0]=linearrgb_to_srgb(value[0]);
 						value[0]=value[0]*255; /* scale to 0-255 range */
 						ivalue=(int)value[0];
 						break;
 					}
 					case 3:  { /* green channel */
+						if(colorcor)
+							value[1]=linearrgb_to_srgb(value[1]);
 						value[1]=value[1]*255; /* scale to 0-255 range */
 						ivalue=(int)value[1];
 						break;
 					}
 					case 4: /*blue channel */
 					{
+						if(colorcor)
+							value[2]=linearrgb_to_srgb(value[2]);
 						value[2]=value[2]*255; /* scale to 0-255 range */
 						ivalue=(int)value[2];
 						break;
 					}
 					case 5: /* luminence */
 					{
+						if(colorcor)
+							linearrgb_to_srgb_v3_v3(&value[0],&value[0]);
 						rgb_to_yuv(value[0],value[1],value[2], &value[0], &value[1], &value[2]);
 						value[0]=value[0]*255; /* scale to 0-255 range */
 						ivalue=(int)value[0];
@@ -270,6 +280,7 @@
 {
 	CompBuf* cbuf;
 	CompBuf* histogram;
+	RenderData *rd=data;
 	float mean, std_dev;
 	int bins[256];
 	int x;
@@ -286,7 +297,7 @@
 	}
 	
 	/*fill bins */
-	fill_bins(node, in[0]->data, bins);
+	fill_bins(node, in[0]->data, bins, rd->color_mgt_flag & R_COLOR_MANAGEMENT);
 
 	/* draw the histogram chart */
 	draw_histogram(node, histogram, bins);





More information about the Bf-blender-cvs mailing list