Fix #32513: incorrect color management in Material draw mode for Cycles.
This commit is contained in:
@@ -135,6 +135,8 @@ int GPU_material_bound(GPUMaterial *material);
|
|||||||
void GPU_material_vertex_attributes(GPUMaterial *material,
|
void GPU_material_vertex_attributes(GPUMaterial *material,
|
||||||
struct GPUVertexAttribs *attrib);
|
struct GPUVertexAttribs *attrib);
|
||||||
|
|
||||||
|
int GPU_material_do_color_management(GPUMaterial *mat);
|
||||||
|
|
||||||
/* Exported shading */
|
/* Exported shading */
|
||||||
|
|
||||||
typedef struct GPUShadeInput {
|
typedef struct GPUShadeInput {
|
||||||
|
@@ -387,7 +387,7 @@ void gpu_material_add_node(GPUMaterial *material, GPUNode *node)
|
|||||||
|
|
||||||
/* Code generation */
|
/* Code generation */
|
||||||
|
|
||||||
static int gpu_do_color_management(GPUMaterial *mat)
|
int GPU_material_do_color_management(GPUMaterial *mat)
|
||||||
{
|
{
|
||||||
return ((mat->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) &&
|
return ((mat->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) &&
|
||||||
!((mat->scene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT)));
|
!((mat->scene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT)));
|
||||||
@@ -1076,7 +1076,7 @@ static void do_material_tex(GPUShadeInput *shi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tex->type==TEX_IMAGE)
|
if (tex->type==TEX_IMAGE)
|
||||||
if (gpu_do_color_management(mat))
|
if (GPU_material_do_color_management(mat))
|
||||||
GPU_link(mat, "srgb_to_linearrgb", tcol, &tcol);
|
GPU_link(mat, "srgb_to_linearrgb", tcol, &tcol);
|
||||||
|
|
||||||
if (mtex->mapto & MAP_COL) {
|
if (mtex->mapto & MAP_COL) {
|
||||||
@@ -1372,7 +1372,7 @@ void GPU_shadeinput_set(GPUMaterial *mat, Material *ma, GPUShadeInput *shi)
|
|||||||
GPU_link(mat, "set_value", GPU_uniform(&ma->amb), &shi->amb);
|
GPU_link(mat, "set_value", GPU_uniform(&ma->amb), &shi->amb);
|
||||||
GPU_link(mat, "shade_view", GPU_builtin(GPU_VIEW_POSITION), &shi->view);
|
GPU_link(mat, "shade_view", GPU_builtin(GPU_VIEW_POSITION), &shi->view);
|
||||||
GPU_link(mat, "vcol_attribute", GPU_attribute(CD_MCOL, ""), &shi->vcol);
|
GPU_link(mat, "vcol_attribute", GPU_attribute(CD_MCOL, ""), &shi->vcol);
|
||||||
if (gpu_do_color_management(mat))
|
if (GPU_material_do_color_management(mat))
|
||||||
GPU_link(mat, "srgb_to_linearrgb", shi->vcol, &shi->vcol);
|
GPU_link(mat, "srgb_to_linearrgb", shi->vcol, &shi->vcol);
|
||||||
GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref);
|
GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref);
|
||||||
}
|
}
|
||||||
@@ -1516,12 +1516,9 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma)
|
|||||||
GPU_material_output_link(mat, outlink);
|
GPU_material_output_link(mat, outlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BKE_scene_use_new_shading_nodes(scene)) {
|
if (GPU_material_do_color_management(mat))
|
||||||
if (gpu_do_color_management(mat))
|
|
||||||
if (mat->outlink)
|
if (mat->outlink)
|
||||||
GPU_link(mat, "linearrgb_to_srgb", mat->outlink, &mat->outlink);
|
GPU_link(mat, "linearrgb_to_srgb", mat->outlink, &mat->outlink);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GPU_material_construct_end(mat);
|
GPU_material_construct_end(mat);
|
||||||
|
|
||||||
|
@@ -69,6 +69,9 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, GPUNod
|
|||||||
|
|
||||||
node_shader_gpu_tex_mapping(mat, node, in, out);
|
node_shader_gpu_tex_mapping(mat, node, in, out);
|
||||||
|
|
||||||
|
if (out[0].link && GPU_material_do_color_management(mat))
|
||||||
|
GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
|
||||||
|
|
||||||
return GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser, ncd));
|
return GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser, ncd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,6 +69,9 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, GPUNodeStack
|
|||||||
|
|
||||||
node_shader_gpu_tex_mapping(mat, node, in, out);
|
node_shader_gpu_tex_mapping(mat, node, in, out);
|
||||||
|
|
||||||
|
if (out[0].link && GPU_material_do_color_management(mat))
|
||||||
|
GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
|
||||||
|
|
||||||
return GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, ncd));
|
return GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, ncd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user