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:
authorMatt Ebb <matt@mke3.net>2009-07-17 06:43:15 +0400
committerMatt Ebb <matt@mke3.net>2009-07-17 06:43:15 +0400
commit1ef729358517248888073be71ba5d3b6e3d723ee (patch)
treedfa33f083ac1afd500e76dcf4bc581394637d0dd /source/blender/imbuf/intern/divers.c
parent70f6255433fcb1f5551199ef7a285a9ab80a3318 (diff)
Colour Management
- 1st stage: Linear Workflow This implements automatic linear workflow in Blender's renderer. With the new Colour Management option on in the Render buttons, all inputs to the renderer and compositor are converted to linear colour space before rendering, and gamma corrected afterwards. In essence, this makes all manual gamma correction with nodes, etc unnecessary, since it's done automatically through the pipeline. It's all explained much better in the notes/doc here, so please have a look: http://wiki.blender.org/index.php/Dev:Source/Blender/Architecture/Colour_Management And an example of the sort of difference it makes: http://mke3.net/blender/devel/rendering/b25_colormanagement_test01.jpg This also enables Colour Management in the default B.blend, and changes the default lamp falloff to inverse square, which is more correct, and much easier to use now it's all gamma corrected properly. Next step is to look into profiles/soft proofing for the compositor. Thanks to brecht for reviewing and fixing some oversights!
Diffstat (limited to 'source/blender/imbuf/intern/divers.c')
-rw-r--r--source/blender/imbuf/intern/divers.c54
1 files changed, 44 insertions, 10 deletions
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 8043e594454..6e1a176a5d2 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -39,6 +39,7 @@
#include "IMB_allocimbuf.h"
#include "IMB_divers.h"
#include "BKE_utildefines.h"
+#include "BKE_colortools.h"
void imb_checkncols(struct ImBuf *ibuf)
{
@@ -176,9 +177,11 @@ void IMB_gamwarp(struct ImBuf *ibuf, double gamma)
void IMB_rect_from_float(struct ImBuf *ibuf)
{
/* quick method to convert floatbuf to byte */
- float *tof = ibuf->rect_float;
+ float *tof = (float *)ibuf->rect_float;
float dither= ibuf->dither;
+ float srgb[3];
int i, channels= ibuf->channels;
+ short profile= ibuf->profile;
unsigned char *to = (unsigned char *) ibuf->rect;
if(tof==NULL) return;
@@ -187,7 +190,24 @@ void IMB_rect_from_float(struct ImBuf *ibuf)
to = (unsigned char *) ibuf->rect;
}
- if(dither==0.0f || channels!=4) {
+ if (profile == IB_PROFILE_SRGB && (channels == 3 || channels == 4)) {
+ if(channels == 3) {
+ for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=3) {
+ srgb[0]= linearrgb_to_srgb(tof[0]);
+ srgb[1]= linearrgb_to_srgb(tof[1]);
+ srgb[2]= linearrgb_to_srgb(tof[2]);
+
+ to[0] = FTOCHAR(srgb[0]);
+ to[1] = FTOCHAR(srgb[1]);
+ to[2] = FTOCHAR(srgb[2]);
+ to[3] = 255;
+ }
+ }
+ else if (channels == 4) {
+ floatbuf_to_srgb_byte(tof, to, 0, ibuf->x, 0, ibuf->y, ibuf->x);
+ }
+ }
+ else if(ELEM(profile, IB_PROFILE_NONE, IB_PROFILE_LINEAR_RGB) && (dither==0.0f || channels!=4)) {
if(channels==1) {
for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof++)
to[1]= to[2]= to[3]= to[0] = FTOCHAR(tof[0]);
@@ -242,14 +262,28 @@ void IMB_float_from_rect(struct ImBuf *ibuf)
tof = ibuf->rect_float;
}
- for (i = ibuf->x * ibuf->y; i > 0; i--)
- {
- tof[0] = ((float)to[0])*(1.0f/255.0f);
- tof[1] = ((float)to[1])*(1.0f/255.0f);
- tof[2] = ((float)to[2])*(1.0f/255.0f);
- tof[3] = ((float)to[3])*(1.0f/255.0f);
- to += 4;
- tof += 4;
+ if (ibuf->profile == IB_PROFILE_SRGB) {
+ /* convert from srgb to linear rgb */
+
+ for (i = ibuf->x * ibuf->y; i > 0; i--)
+ {
+ tof[0] = srgb_to_linearrgb(((float)to[0])*(1.0f/255.0f));
+ tof[1] = srgb_to_linearrgb(((float)to[1])*(1.0f/255.0f));
+ tof[2] = srgb_to_linearrgb(((float)to[2])*(1.0f/255.0f));
+ tof[3] = ((float)to[3])*(1.0f/255.0f);
+ to += 4;
+ tof += 4;
+ }
+ } else {
+ for (i = ibuf->x * ibuf->y; i > 0; i--)
+ {
+ tof[0] = ((float)to[0])*(1.0f/255.0f);
+ tof[1] = ((float)to[1])*(1.0f/255.0f);
+ tof[2] = ((float)to[2])*(1.0f/255.0f);
+ tof[3] = ((float)to[3])*(1.0f/255.0f);
+ to += 4;
+ tof += 4;
+ }
}
}