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-12-02 10:56:34 +0300
committerMatt Ebb <matt@mke3.net>2009-12-02 10:56:34 +0300
commitb89138564eee9b576263518df0ed5dc045668f75 (patch)
tree234313b65a3715b5589f50d34aa6c6534a406d30 /source/blender/gpu
parentc758f6589e5d91e9fa2086a7db744282f2ea1e55 (diff)
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color management works internally. While the previous method worked well for rendering, was a smaller transition and had some advantages over this new method, it was a bit more ambiguous, and was making things difficult for other areas such as compositing. This implementation now considers all color data (with only a couple of exceptions such as brush colors) to be stored in linear RGB color space, rather than sRGB as previously. This brings it in line with Nuke, which also operates this way, quite successfully. Color swatches, pickers, color ramp display are now gamma corrected to display gamma so you can see what you're doing, but the numbers themselves are considered linear. This makes understanding blending modes more clear (a 0.5 value on overlay will not change the result now) as well as making color swatches act more predictably in the compositor, however bringing over color values from applications like photoshop or gimp, that operate in a gamma space, will give identical results. This commit will convert over existing files saved by earlier 2.5 versions to work generally the same, though there may be some slight differences with things like textures. Now that we're set on changing other areas of shading, this won't be too disruptive overall. I've made a diagram explaining the pipeline here: http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png and some docs here: http://www.blender.org/development/release-logs/blender-250/color-management/
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/intern/gpu_draw.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 75e8073aafd..c2cf4dfa9fd 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -34,6 +34,8 @@
#include "GL/glew.h"
+#include "BLI_math.h"
+
#include "DNA_image_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
@@ -856,6 +858,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
GPUMaterial *gpumat;
GPUBlendMode blendmode;
int a;
+ int gamma = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
/* initialize state */
memset(&GMS, 0, sizeof(GMS));
@@ -930,6 +933,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
GMS.matbuf[a][0][0]= ma->r;
GMS.matbuf[a][0][1]= ma->g;
GMS.matbuf[a][0][2]= ma->b;
+ if(gamma) linearrgb_to_srgb_v3_v3(&GMS.matbuf[a][0][0], &GMS.matbuf[a][0][0]);
} else {
GMS.matbuf[a][0][0]= (ma->ref+ma->emit)*ma->r;
GMS.matbuf[a][0][1]= (ma->ref+ma->emit)*ma->g;
@@ -939,6 +943,11 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
GMS.matbuf[a][1][1]= ma->spec*ma->specg;
GMS.matbuf[a][1][2]= ma->spec*ma->specb;
GMS.matbuf[a][1][3]= 1.0;
+
+ if(gamma) {
+ linearrgb_to_srgb_v3_v3(&GMS.matbuf[a][0][0], &GMS.matbuf[a][0][0]);
+ linearrgb_to_srgb_v3_v3(&GMS.matbuf[a][1][0], &GMS.matbuf[a][1][0]);
+ }
}
blendmode = (ma->alpha == 1.0f)? GPU_BLEND_SOLID: GPU_BLEND_ALPHA;