Revision: 36566
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36566
Author:   blendix
Date:     2011-05-09 09:03:08 +0000 (Mon, 09 May 2011)
Log Message:
-----------
Cycles: fix color difference between render / 3d view with color management 
disabled.

Modified Paths:
--------------
    branches/cycles/intern/cycles/blender/blender_session.cpp
    branches/cycles/intern/cycles/util/util_color.h

Modified: branches/cycles/intern/cycles/blender/blender_session.cpp
===================================================================
--- branches/cycles/intern/cycles/blender/blender_session.cpp   2011-05-09 
08:20:39 UTC (rev 36565)
+++ branches/cycles/intern/cycles/blender/blender_session.cpp   2011-05-09 
09:03:08 UTC (rev 36566)
@@ -130,14 +130,17 @@
 
        vector<float4> buffer(width*height);
        float fac = 1.0f/255.0f;
+       bool color_management = b_scene.render().use_color_management();
 
        /* normalize */
        for(int i = width*height - 1; i >= 0; i--) {
                uchar4 f = rgba[i];
-               float r = color_srgb_to_scene_linear(f.x*fac);
-               float g = color_srgb_to_scene_linear(f.y*fac);
-               float b = color_srgb_to_scene_linear(f.z*fac);
-               buffer[i] = make_float4(r, g, b, 1.0f);
+               float3 rgb = make_float3(f.x, f.y, f.z)*fac;
+
+               if(color_management)
+                       rgb = color_srgb_to_scene_linear(rgb);
+
+               buffer[i] = make_float4(rgb.x, rgb.y, rgb.z, 1.0f);
        }
 
        struct RenderResult *rrp = 
RE_engine_begin_result((RenderEngine*)b_engine.ptr.data, 0, 0, width, height);

Modified: branches/cycles/intern/cycles/util/util_color.h
===================================================================
--- branches/cycles/intern/cycles/util/util_color.h     2011-05-09 08:20:39 UTC 
(rev 36565)
+++ branches/cycles/intern/cycles/util/util_color.h     2011-05-09 09:03:08 UTC 
(rev 36566)
@@ -40,6 +40,22 @@
                return 1.055f * pow(c, 1.0f/2.4f) - 0.055f;
 }
 
+__device float3 color_srgb_to_scene_linear(float3 c)
+{
+       return make_float3(
+               color_srgb_to_scene_linear(c.x),
+               color_srgb_to_scene_linear(c.y),
+               color_srgb_to_scene_linear(c.z));
+}
+
+__device float3 color_scene_linear_to_srgb(float3 c)
+{
+       return make_float3(
+               color_scene_linear_to_srgb(c.x),
+               color_scene_linear_to_srgb(c.y),
+               color_scene_linear_to_srgb(c.z));
+}
+
 CCL_NAMESPACE_END
 
 #endif /* __UTIL_COLOR_H__ */

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to