diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-10-22 21:34:06 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-10-22 21:34:06 +0400 |
commit | 3285d47842657161b2206ccb2b29f34ef51eab99 (patch) | |
tree | d57a4d3f4b24e875afacd8d82d6ff8ccf2d2f6cc /source/blender/nodes | |
parent | 6e62491c5a101ee36ec48db97e4a4f4945f5eada (diff) |
Fix #32930: texture colors in material nodes (blender internal) are brighter than normal
There was a missing byte buffer linearization for shader nodes.
Also fixed incorrect image input color space refresh when image is packed.
Diffstat (limited to 'source/blender/nodes')
3 files changed, 40 insertions, 8 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index 311ae3a9017..8c3f243169f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -27,6 +27,8 @@ #include "../node_shader_util.h" +#include "IMB_colormanagement.h" + /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_tex_environment_in[] = { @@ -60,6 +62,7 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, GPUNod ImageUser *iuser= NULL; NodeTexImage *tex = node->storage; int ncd = tex->color_space == SHD_COLORSPACE_NONE; + int ret; if (!ima) return GPU_stack_link(mat, "node_tex_environment_empty", in, out); @@ -69,10 +72,17 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, GPUNod 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); + ret = GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser, ncd)); + + if (ret) { + if (GPU_material_do_color_management(mat) && + IMB_colormanagement_colorspace_is_data(ima->colorspace_settings.name) == FALSE) + { + 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 ret; } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index 52f8c21fbb0..342e06ff050 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -27,6 +27,8 @@ #include "../node_shader_util.h" +#include "IMB_colormanagement.h" + /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_tex_image_in[] = { @@ -60,6 +62,7 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, GPUNodeStack ImageUser *iuser= NULL; NodeTexImage *tex = node->storage; int ncd = tex->color_space == SHD_COLORSPACE_NONE; + int ret; if (!ima) return GPU_stack_link(mat, "node_tex_image_empty", in, out); @@ -69,10 +72,17 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, GPUNodeStack 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); + ret = GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, ncd)); + + if (ret) { + if (GPU_material_do_color_management(mat) && + IMB_colormanagement_colorspace_is_data(ima->colorspace_settings.name) == FALSE) + { + 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 ret; } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c index c27a95da5a0..b39f0e62fa9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_texture.c +++ b/source/blender/nodes/shader/nodes/node_shader_texture.c @@ -32,6 +32,8 @@ #include "DNA_texture_types.h" +#include "IMB_colormanagement.h" + #include "node_shader_util.h" /* **************** TEXTURE ******************** */ @@ -122,8 +124,18 @@ static int gpu_shader_texture(GPUMaterial *mat, bNode *node, GPUNodeStack *in, G Tex *tex = (Tex*)node->id; if (tex && tex->type == TEX_IMAGE && tex->ima) { - GPUNodeLink *texlink = GPU_image(tex->ima, NULL, FALSE); - return GPU_stack_link(mat, "texture_image", in, out, texlink); + GPUNodeLink *texlink = GPU_image(tex->ima, &tex->iuser, FALSE); + int ret = GPU_stack_link(mat, "texture_image", in, out, texlink); + + if (ret) { + if (GPU_material_do_color_management(mat) && + IMB_colormanagement_colorspace_is_data(tex->ima->colorspace_settings.name) == FALSE) + { + GPU_link(mat, "srgb_to_linearrgb", out[1].link, &out[1].link); + } + } + + return ret; } else return 0; |