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/editors/screen
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/editors/screen')
-rw-r--r--source/blender/editors/screen/glutil.c25
-rw-r--r--source/blender/editors/screen/screen_ops.c52
2 files changed, 48 insertions, 29 deletions
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index a23487effa1..5312ca26906 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -35,6 +35,7 @@
#include "DNA_listBase.h"
#include "BKE_utildefines.h"
+#include "BKE_colortools.h"
#include "BLI_arithb.h"
#include "BLI_threads.h"
@@ -482,27 +483,20 @@ void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void *
glaDrawPixelsTexScaled(x, y, img_w, img_h, format, rect, 1.0f, 1.0f);
}
-void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int row_w, float *rectf)
+void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int row_w, float *rectf, int gamma_correct)
{
- float *rf;
- int x, y;
- char *rect32, *rc;
+ unsigned char *rect32;
/* copy imgw-imgh to a temporal 32 bits rect */
if(img_w<1 || img_h<1) return;
- rc= rect32= MEM_mallocN(img_w*img_h*sizeof(int), "temp 32 bits");
+ rect32= MEM_mallocN(img_w*img_h*sizeof(int), "temp 32 bits");
- for(y=0; y<img_h; y++) {
- rf= rectf;
- for(x=0; x<img_w; x++, rf+=4, rc+=4) {
- rc[0]= FTOCHAR(rf[0]);
- rc[1]= FTOCHAR(rf[1]);
- rc[2]= FTOCHAR(rf[2]);
- rc[3]= FTOCHAR(rf[3]);
- }
- rectf+= 4*row_w;
- }
+ if (gamma_correct) {
+ floatbuf_to_srgb_byte(rectf, rect32, 0, img_w, 0, img_h, img_w);
+ } else {
+ floatbuf_to_byte(rectf, rect32, 0, img_w, 0, img_h, img_w);
+ }
glaDrawPixelsSafe(fx, fy, img_w, img_h, img_w, GL_RGBA, GL_UNSIGNED_BYTE, rect32);
@@ -855,4 +849,3 @@ void bglFlush(void)
#endif
}
-
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 07aaf0f9b58..812c9f11069 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -41,6 +41,7 @@
#include "DNA_scene_types.h"
#include "BKE_blender.h"
+#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_global.h"
@@ -2575,21 +2576,46 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
rectf+= 4*(rr->rectx*ymin + xmin);
rectc= (char *)(ibuf->rect + ibuf->x*rymin + rxmin);
- for(y1= 0; y1<ymax; y1++) {
- float *rf= rectf;
- char *rc= rectc;
-
- /* XXX temp. because crop offset */
- if( rectc >= (char *)(ibuf->rect)) {
- for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
- rc[0]= FTOCHAR(rf[0]);
- rc[1]= FTOCHAR(rf[1]);
- rc[2]= FTOCHAR(rf[2]);
- rc[3]= FTOCHAR(rf[3]);
+ /* XXX make nice consistent functions for this */
+ if (rj->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) {
+ for(y1= 0; y1<ymax; y1++) {
+ float *rf= rectf;
+ float srgb[3];
+ char *rc= rectc;
+
+ /* XXX temp. because crop offset */
+ if( rectc >= (char *)(ibuf->rect)) {
+ for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
+ srgb[0]= linearrgb_to_srgb(rf[0]);
+ srgb[1]= linearrgb_to_srgb(rf[1]);
+ srgb[2]= linearrgb_to_srgb(rf[2]);
+
+ rc[0]= FTOCHAR(srgb[0]);
+ rc[1]= FTOCHAR(srgb[1]);
+ rc[2]= FTOCHAR(srgb[2]);
+ rc[3]= FTOCHAR(rf[3]);
+ }
+ }
+ rectf += 4*rr->rectx;
+ rectc += 4*ibuf->x;
+ }
+ } else {
+ for(y1= 0; y1<ymax; y1++) {
+ float *rf= rectf;
+ char *rc= rectc;
+
+ /* XXX temp. because crop offset */
+ if( rectc >= (char *)(ibuf->rect)) {
+ for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
+ rc[0]= FTOCHAR(rf[0]);
+ rc[1]= FTOCHAR(rf[1]);
+ rc[2]= FTOCHAR(rf[2]);
+ rc[3]= FTOCHAR(rf[3]);
+ }
}
+ rectf += 4*rr->rectx;
+ rectc += 4*ibuf->x;
}
- rectf += 4*rr->rectx;
- rectc += 4*ibuf->x;
}
/* make jobs timer to send notifier */