Cycles: fix color difference between render / 3d view with color management disabled.

This commit is contained in:
Brecht Van Lommel 2011-05-09 09:03:08 +00:00
parent d5929b452e
commit 31f44d8142
2 changed files with 23 additions and 4 deletions

@ -130,14 +130,17 @@ void BlenderSession::write_render_result()
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);

@ -40,6 +40,22 @@ __device float color_scene_linear_to_srgb(float c)
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__ */