Fix for ben dansie, incorrect gamma with render baking.
authorMatt Ebb <matt@mke3.net>
Fri, 26 Mar 2010 01:31:43 +0000 (01:31 +0000)
committerMatt Ebb <matt@mke3.net>
Fri, 26 Mar 2010 01:31:43 +0000 (01:31 +0000)
Linear/gamma issues weren't really considered in baking yet.

release/scripts/ui/space_image.py
source/blender/editors/space_image/image_buttons.c
source/blender/render/intern/source/rendercore.c

index 4b4ff15..b8c5c01 100644 (file)
@@ -342,7 +342,7 @@ class IMAGE_PT_image_properties(bpy.types.Panel):
         # ima = sima.image
         iuser = sima.image_user
 
-        layout.template_image(sima, "image", iuser, compact=True)
+        layout.template_image(sima, "image", iuser)
 
 
 class IMAGE_PT_game_properties(bpy.types.Panel):
index 5f96c4a..283d849 100644 (file)
@@ -883,7 +883,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn
                }
                else {
                        row= uiLayoutRow(layout, 0);
-                       uiItemR(row, &imaptr, "source", (compact)? 0: UI_ITEM_R_EXPAND, NULL, 0);
+                       uiItemR(row, &imaptr, "source", 0, NULL, 0);
 
                        if(ima->source != IMA_SRC_GENERATED) {
                                row= uiLayoutRow(layout, 1);
index cf1f339..7375ea0 100644 (file)
@@ -2211,12 +2211,23 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int quad, int
        }
        else {
                char *col= (char *)(bs->rect + bs->rectx*y + x);
-               col[0]= FTOCHAR(shr.combined[0]);
-               col[1]= FTOCHAR(shr.combined[1]);
-               col[2]= FTOCHAR(shr.combined[2]);
-               
+
+               if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE) &&     (R.r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
+                       float srgb[3];
+                       srgb[0]= linearrgb_to_srgb(shr.combined[0]);
+                       srgb[1]= linearrgb_to_srgb(shr.combined[1]);
+                       srgb[2]= linearrgb_to_srgb(shr.combined[2]);
+                       
+                       col[0]= FTOCHAR(srgb[0]);
+                       col[1]= FTOCHAR(srgb[1]);
+                       col[2]= FTOCHAR(srgb[2]);
+               } else {
+                       col[0]= FTOCHAR(shr.combined[0]);
+                       col[1]= FTOCHAR(shr.combined[1]);
+                       col[2]= FTOCHAR(shr.combined[2]);
+               }
                
-               if (bs->type==RE_BAKE_ALL || bs->type==RE_BAKE_TEXTURE) {
+               if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE)) {
                        col[3]= FTOCHAR(shr.alpha);
                } else {
                        col[3]= 255;
@@ -2643,6 +2654,8 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
                ima->id.flag |= LIB_DOIT;
                if (ibuf)
                        ibuf->userdata = NULL; /* use for masking if needed */
+               if(ibuf->rect_float)
+                       ibuf->profile = IB_PROFILE_LINEAR_RGB;
        }
        
        BLI_init_threads(&threads, do_bake_thread, re->r.threads);