Bugfix #26388
authorTon Roosendaal <ton@blender.org>
Mon, 7 Mar 2011 11:51:09 +0000 (11:51 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 7 Mar 2011 11:51:09 +0000 (11:51 +0000)
Actually a todo item I forgot:

Material nodes previews now follow the scene "color managenent"
setting.

source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/intern/node.c
source/blender/nodes/intern/SHD_nodes/SHD_material.c
source/blender/nodes/intern/SHD_nodes/SHD_output.c
source/blender/nodes/intern/SHD_nodes/SHD_texture.c
source/blender/nodes/intern/TEX_util.c
source/blender/render/extern/include/RE_shader_ext.h
source/blender/render/intern/source/shadeinput.c

index 41e41eab78f7fe1b889f4f60c3babc79fb069f8d..a126f405d097e56ae6db2680958bde14ecb3f5c5 100644 (file)
@@ -168,7 +168,7 @@ void                        ntreeLocalMerge(struct bNodeTree *localtree, struct bNodeTree *ntree);
 
 void                   nodeVerifyType(struct bNodeTree *ntree, struct bNode *node);
 
-void                   nodeAddToPreview(struct bNode *, float *, int, int);
+void                   nodeAddToPreview(struct bNode *, float *, int, int, int);
 
 void                   nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
 void                   nodeUniqueName(struct bNodeTree *ntree, struct bNode *node);
index 1f8cd1ca152d4a66064853df185c00b934736ff1..6f7963f4765ceb04205753854f91f6b93c69f741 100644 (file)
@@ -1325,7 +1325,7 @@ void ntreeClearPreview(bNodeTree *ntree)
 /* hack warning! this function is only used for shader previews, and 
 since it gets called multiple times per pixel for Ztransp we only
 add the color once. Preview gets cleared before it starts render though */
-void nodeAddToPreview(bNode *node, float *col, int x, int y)
+void nodeAddToPreview(bNode *node, float *col, int x, int y, int do_manage)
 {
        bNodePreview *preview= node->preview;
        if(preview) {
@@ -1333,7 +1333,7 @@ void nodeAddToPreview(bNode *node, float *col, int x, int y)
                        if(x<preview->xsize && y<preview->ysize) {
                                unsigned char *tar= preview->rect+ 4*((preview->xsize*y) + x);
                                
-                               if(TRUE) {
+                               if(do_manage) {
                                        tar[0]= FTOCHAR(linearrgb_to_srgb(col[0]));
                                        tar[1]= FTOCHAR(linearrgb_to_srgb(col[1]));
                                        tar[2]= FTOCHAR(linearrgb_to_srgb(col[2]));
index a95968e7fc9be5717f67d7253d1a324a73b3e63e..317dd07f8fee5f52a4aec881a7b16598172d6396 100644 (file)
@@ -155,7 +155,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in,
                col[3]= shrnode.alpha;
                
                if(shi->do_preview)
-                       nodeAddToPreview(node, col, shi->xs, shi->ys);
+                       nodeAddToPreview(node, col, shi->xs, shi->ys, shi->do_manage);
                
                VECCOPY(out[MAT_OUT_COLOR]->vec, col);
                out[MAT_OUT_ALPHA]->vec[0]= shrnode.alpha;
index 4b6488cf4e025a9a2a600aac85a5219481059835..e42caabff34d51e8b44ce8d1c0a6bd042b350938 100644 (file)
@@ -52,7 +52,7 @@ static void node_shader_exec_output(void *data, bNode *node, bNodeStack **in, bN
                nodestack_get_vec(col+3, SOCK_VALUE, in[1]);
                
                if(shi->do_preview) {
-                       nodeAddToPreview(node, col, shi->xs, shi->ys);
+                       nodeAddToPreview(node, col, shi->xs, shi->ys, shi->do_manage);
                        node->lasty= shi->ys;
                }
                
index c2fb18a939b777be667cd39c509a9c03b02f470c..249e4eeca5dce63524984dd5b5e5ae628d0e5458 100644 (file)
@@ -116,7 +116,7 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b
                VECCOPY(out[2]->vec, nor);
                
                if(shi->do_preview)
-                       nodeAddToPreview(node, out[1]->vec, shi->xs, shi->ys);
+                       nodeAddToPreview(node, out[1]->vec, shi->xs, shi->ys, shi->do_manage);
                
        }
 }
index da047fc9a870b43d866de71df039e0a6bc60f29d..51b3c6d909f1108069d500d67f66a8d549fe0c37 100644 (file)
@@ -124,7 +124,7 @@ void tex_do_preview(bNode *node, float *co, float *col)
                int xs= ((co[0] + 1.0f)*0.5f)*preview->xsize;
                int ys= ((co[1] + 1.0f)*0.5f)*preview->ysize;
 
-               nodeAddToPreview(node, col, xs, ys);
+               nodeAddToPreview(node, col, xs, ys, 0); /* 0 = no color management */
        }
 }
 
index ca04990efadf55ac7af573c86212d3345dd0e684..958c19ab9cae6578faf5f5dacd72943d6df0399d 100644 (file)
@@ -174,6 +174,7 @@ typedef struct ShadeInput
 
        /* from initialize, part or renderlayer */
        short do_preview;               /* for nodes, in previewrender */
+       short do_manage;                /* color management flag */
        short thread, sample;   /* sample: ShadeSample array index */
        short nodes;                    /* indicate node shading, temp hack to prevent recursion */
        
index f4f3cb67a91ef46448312ef4de7c17809e213709..d34ef85baa429a0a3400db2a017bdd65ae0fa28a 100644 (file)
@@ -582,7 +582,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert
                }
        }
        
-       if (R.r.color_mgt_flag & R_COLOR_MANAGEMENT) {
+       if (shi->do_manage) {
                if(mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) {
                        srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol);
                }
@@ -1315,7 +1315,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
        } /* else {
         Note! For raytracing winco is not set, important because thus means all shader input's need to have their variables set to zero else in-initialized values are used
        */
-       if (R.r.color_mgt_flag & R_COLOR_MANAGEMENT) {
+       if (shi->do_manage) {
                if(mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) {
                        srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol);
                }
@@ -1334,6 +1334,7 @@ void shade_input_initialize(ShadeInput *shi, RenderPart *pa, RenderLayer *rl, in
        shi->sample= sample;
        shi->thread= pa->thread;
        shi->do_preview= (R.r.scemode & R_MATNODE_PREVIEW) != 0;
+       shi->do_manage= (R.r.color_mgt_flag & R_COLOR_MANAGEMENT);
        shi->lay= rl->lay;
        shi->layflag= rl->layflag;
        shi->passflag= rl->passflag;