Color Management, Stage 2: Switch color pipeline to use OpenColorIO
[blender.git] / source / blender / render / intern / source / render_texture.c
index 4d3b9c2493ebcbacfb845adef919191c63247636..6d22d8991b404764dcf44d82cbaffd82ead47748 100644 (file)
@@ -50,6 +50,7 @@
 
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
 
 #include "BKE_colortools.h"
 #include "BKE_image.h"
@@ -1226,8 +1227,8 @@ int multitex_nodes(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
                                ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser);
                                
                                /* don't linearize float buffers, assumed to be linear */
-                               if (ibuf && !(ibuf->rect_float) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT)
-                                       srgb_to_linearrgb_v3_v3(&texres->tr, &texres->tr);
+                               if (ibuf && !(ibuf->rect_float))
+                                       IMB_colormanagement_colorspace_to_scene_linear_v3(&texres->tr, ibuf->rect_colorspace);
                        }
                }
                else {
@@ -2379,8 +2380,8 @@ void do_material_tex(ShadeInput *shi, Render *re)
                                        ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser);
                                        
                                        /* don't linearize float buffers, assumed to be linear */
-                                       if (ibuf && !(ibuf->rect_float) && re->r.color_mgt_flag & R_COLOR_MANAGEMENT)
-                                               srgb_to_linearrgb_v3_v3(tcol, tcol);
+                                       if (ibuf && !(ibuf->rect_float))
+                                               IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace);
                                }
                                
                                if (mtex->mapto & MAP_COL) {
@@ -2891,8 +2892,8 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4])
                        ImBuf *ibuf = BKE_image_get_ibuf(ima, &mtex->tex->iuser);
                        
                        /* don't linearize float buffers, assumed to be linear */
-                       if (ibuf && !(ibuf->rect_float) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT)
-                               srgb_to_linearrgb_v3_v3(&texres.tr, &texres.tr);
+                       if (ibuf && !(ibuf->rect_float))
+                               IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace);
                }
 
                fact= texres.tin*mtex->colfac;
@@ -3106,8 +3107,8 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h
                                        ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser);
                                        
                                        /* don't linearize float buffers, assumed to be linear */
-                                       if (ibuf && !(ibuf->rect_float) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT)
-                                               srgb_to_linearrgb_v3_v3(tcol, tcol);
+                                       if (ibuf && !(ibuf->rect_float))
+                                               IMB_colormanagement_colorspace_to_scene_linear_v3(tcol, ibuf->rect_colorspace);
                                }
 
                                if (mtex->mapto & WOMAP_HORIZ) {
@@ -3320,8 +3321,8 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r
                                        ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser);
                                        
                                        /* don't linearize float buffers, assumed to be linear */
-                                       if (ibuf && !(ibuf->rect_float) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT)
-                                               srgb_to_linearrgb_v3_v3(&texres.tr, &texres.tr);
+                                       if (ibuf && !(ibuf->rect_float))
+                                               IMB_colormanagement_colorspace_to_scene_linear_v3(&texres.tr, ibuf->rect_colorspace);
                                }
 
                                /* lamp colors were premultiplied with this */