Actually a todo item I forgot:

Material nodes previews now follow the scene "color managenent"
setting.
This commit is contained in:
Ton Roosendaal
2011-03-07 11:51:09 +00:00
parent c544d3ffb8
commit daff7a447e
8 changed files with 11 additions and 9 deletions

View 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);

View 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]));

View 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;

View 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;
}

View 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);
}
}

View 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 */
}
}

View 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 */

View 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;