Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-10-22 21:34:06 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-10-22 21:34:06 +0400
commit3285d47842657161b2206ccb2b29f34ef51eab99 (patch)
treed57a4d3f4b24e875afacd8d82d6ff8ccf2d2f6cc /source/blender
parent6e62491c5a101ee36ec48db97e4a4f4945f5eada (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')
-rw-r--r--source/blender/blenkernel/BKE_image.h1
-rw-r--r--source/blender/blenkernel/intern/image.c9
-rw-r--r--source/blender/imbuf/IMB_colormanagement.h2
-rw-r--r--source/blender/imbuf/intern/colormanagement.c7
-rw-r--r--source/blender/makesrna/intern/rna_color.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_environment.c16
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c16
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_texture.c16
-rw-r--r--source/blender/render/intern/source/render_texture.c8
9 files changed, 70 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 5e5f58f73fe..1875fd66628 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -127,6 +127,7 @@ enum {
#define IMA_SIGNAL_SRC_CHANGE 5
/* image-user gets a new image, check settings */
#define IMA_SIGNAL_USER_NEW_IMAGE 6
+#define IMA_SIGNAL_COLORMANAGE 7
#define IMA_CHAN_FLAG_BW 1
#define IMA_CHAN_FLAG_RGB 2
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index d291380b941..037f7331f3f 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2142,6 +2142,15 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
}
}
break;
+ case IMA_SIGNAL_COLORMANAGE:
+ image_free_buffers(ima);
+
+ ima->ok = 1;
+
+ if (iuser)
+ iuser->ok = 1;
+
+ break;
}
/* don't use notifiers because they are not 100% sure to succeeded
diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h
index 0653956e113..12f23e832c7 100644
--- a/source/blender/imbuf/IMB_colormanagement.h
+++ b/source/blender/imbuf/IMB_colormanagement.h
@@ -62,6 +62,8 @@ void IMB_colormanagement_check_is_data(struct ImBuf *ibuf, const char *name);
void IMB_colormanagement_assign_float_colorspace(struct ImBuf *ibuf, const char *name);
void IMB_colormanagement_assign_rect_colorspace(struct ImBuf *ibuf, const char *name);
+int IMB_colormanagement_colorspace_is_data(const char *name);
+
/* ** Color space transformation functions ** */
void IMB_colormanagement_transform(float *buffer, int width, int height, int channels,
const char *from_colorspace, const char *to_colorspace, int predivide);
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index ff474d85a8c..8cd2a707dd3 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -1113,6 +1113,13 @@ void IMB_colormanagement_assign_rect_colorspace(ImBuf *ibuf, const char *name)
ibuf->colormanage_flag &= ~IMB_COLORMANAGE_IS_DATA;
}
+int IMB_colormanagement_colorspace_is_data(const char *name)
+{
+ ColorSpace *colorspace = colormanage_colorspace_get_named(name);
+
+ return colorspace->is_data;
+}
+
/*********************** Threaded display buffer transform routines *************************/
typedef struct DisplayBufferThread {
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 1ba2fc1ee7e..d898a5ac5c7 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -474,7 +474,9 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain)
if (GS(id->name) == ID_IM) {
Image *ima = (Image *) id;
- BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
+ DAG_id_tag_update(&ima->id, 0);
+
+ BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE);
WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
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;
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index dc99ee02a19..9cdf7da5a44 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -1262,6 +1262,14 @@ int multitex_nodes(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int os
do_2d_mapping(&localmtex, texvec_l, NULL, NULL, dxt_l, dyt_l);
rgbnor= multitex(tex, texvec_l, dxt_l, dyt_l, osatex, texres, thread, which_output);
+
+ {
+ ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser);
+
+ /* don't linearize float buffers, assumed to be linear */
+ if (ibuf && !(ibuf->rect_float) && R.scene_color_manage)
+ IMB_colormanagement_colorspace_to_scene_linear_v3(&texres->tr, ibuf->rect_colorspace);
+ }
}
return rgbnor;