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-09-15 14:05:07 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-09-15 14:05:07 +0400
commita73dd3476e7d180d3320afc04d218ce22f2f3bfc (patch)
treea540f5657bc9e8692eb0d3417de71393bad6bece /source/blender/compositor/operations
parentb93da9b01e163158a830872d29f8bd874f63d54d (diff)
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
Diffstat (limited to 'source/blender/compositor/operations')
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cpp1
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.h7
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cpp13
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_SplitViewerOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_ViewerBaseOperation.cpp31
-rw-r--r--source/blender/compositor/operations/COM_ViewerBaseOperation.h13
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp16
9 files changed, 63 insertions, 53 deletions
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp
index 4ec5643c0bb..fb3efbb67ed 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_ImageOperation.cpp
@@ -33,6 +33,7 @@ extern "C" {
#include "RE_render_ext.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+ #include "IMB_colormanagement.h"
}
BaseImageOperation::BaseImageOperation() : NodeOperation()
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index b72875ab2f9..21ecfdb5272 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -31,9 +31,12 @@
#include "BKE_global.h"
#include "BKE_main.h"
+#include "DNA_color_types.h"
+
extern "C" {
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
+ #include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
}
@@ -91,7 +94,8 @@ static void write_buffer_rect(rcti *rect, const bNodeTree *tree,
OutputSingleLayerOperation::OutputSingleLayerOperation(
- const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path)
+ const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path,
+ const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings)
{
this->m_rd = rd;
this->m_tree = tree;
@@ -104,6 +108,9 @@ OutputSingleLayerOperation::OutputSingleLayerOperation(
this->m_format = format;
BLI_strncpy(this->m_path, path, sizeof(this->m_path));
+
+ this->m_viewSettings = viewSettings;
+ this->m_displaySettings = displaySettings;
}
void OutputSingleLayerOperation::initExecution()
@@ -131,8 +138,7 @@ void OutputSingleLayerOperation::deinitExecution()
ibuf->mall |= IB_rectfloat;
ibuf->dither = this->m_rd->dither_intensity;
- if (this->m_rd->color_mgt_flag & R_COLOR_MANAGEMENT)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
+ IMB_display_buffer_to_imbuf_rect(ibuf, m_viewSettings, m_displaySettings);
BKE_makepicstring(filename, this->m_path, bmain->name, this->m_rd->cfra, this->m_format->imtype,
(this->m_rd->scemode & R_EXTENSION), true);
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h
index 532242c97ce..69d1ad48ced 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.h
@@ -28,6 +28,8 @@
#include "BLI_rect.h"
#include "BLI_path_util.h"
+#include "DNA_color_types.h"
+
#include "intern/openexr/openexr_multi.h"
/* Writes the image to a single-layer file. */
@@ -43,8 +45,11 @@ private:
DataType m_datatype;
SocketReader *m_imageInput;
+ const ColorManagedViewSettings *m_viewSettings;
+ const ColorManagedDisplaySettings *m_displaySettings;
public:
- OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path);
+ OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path,
+ const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings);
void executeRegion(rcti *rect, unsigned int tileNumber);
bool isOutputOperation(bool rendering) const { return true; }
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp
index aff374cdded..6e58b277f66 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cpp
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -35,16 +35,19 @@ extern "C" {
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+ #include "IMB_colormanagement.h"
}
-PreviewOperation::PreviewOperation() : NodeOperation()
+PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings) : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->m_outputBuffer = NULL;
this->m_input = NULL;
this->m_divider = 1.0f;
this->m_node = NULL;
+ this->m_viewSettings = viewSettings;
+ this->m_displaySettings = displaySettings;
}
void PreviewOperation::initExecution()
@@ -82,6 +85,10 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber)
{
int offset;
float color[4];
+ struct ColormanageProcessor *cm_processor;
+
+ cm_processor = IMB_colormanagement_display_processor_new(this->m_viewSettings, this->m_displaySettings);
+
for (int y = rect->ymin; y < rect->ymax; y++) {
offset = (y * getWidth() + rect->xmin) * 4;
for (int x = rect->xmin; x < rect->xmax; x++) {
@@ -93,11 +100,13 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber)
color[2] = 0.0f;
color[3] = 1.0f;
this->m_input->read(color, rx, ry, COM_PS_NEAREST);
- linearrgb_to_srgb_v4(color, color);
+ IMB_colormanagement_processor_apply_v4(cm_processor, color);
F4TOCHAR4(color, this->m_outputBuffer + offset);
offset += 4;
}
}
+
+ IMB_colormanagement_processor_free(cm_processor);
}
bool PreviewOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h
index ffd80ff27af..9e774d0e41b 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.h
+++ b/source/blender/compositor/operations/COM_PreviewOperation.h
@@ -24,6 +24,7 @@
#define _COM_PreviewOperation_h
#include "COM_NodeOperation.h"
#include "DNA_image_types.h"
+#include "DNA_color_types.h"
#include "BLI_rect.h"
class PreviewOperation : public NodeOperation {
@@ -37,8 +38,10 @@ protected:
SocketReader *m_input;
float m_divider;
+ const ColorManagedViewSettings *m_viewSettings;
+ const ColorManagedDisplaySettings *m_displaySettings;
public:
- PreviewOperation();
+ PreviewOperation(const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings);
bool isOutputOperation(bool rendering) const { return true; }
void initExecution();
void deinitExecution();
diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
index d59d1f9f10d..7325e32a863 100644
--- a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
@@ -62,7 +62,6 @@ void SplitViewerOperation::deinitExecution()
void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
{
float *buffer = this->m_outputBuffer;
- unsigned char *bufferDisplay = this->m_outputBufferDisplay;
if (!buffer) return;
int x1 = rect->xmin;
@@ -76,7 +75,6 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
for (y = y1; y < y2; y++) {
for (x = x1; x < x2; x++) {
bool image1;
- float srgb[4];
image1 = this->m_xSplit ? x > perc : y > perc;
if (image1) {
this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST);
@@ -84,21 +82,7 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
else {
this->m_image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST);
}
- /// @todo: linear conversion only when scene color management is selected, also check predivide.
- if (this->m_doColorManagement) {
- if (this->m_doColorPredivide) {
- linearrgb_to_srgb_predivide_v4(srgb, buffer + offset);
- }
- else {
- linearrgb_to_srgb_v4(srgb, buffer + offset);
- }
- }
- else {
- copy_v4_v4(srgb, buffer + offset);
- }
-
- rgba_float_to_uchar(bufferDisplay + offset, srgb);
-
+
offset += 4;
}
offset += (this->getWidth() - (x2 - x1)) * 4;
diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
index f443c33cd54..d9ca131721f 100644
--- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
@@ -34,6 +34,7 @@ extern "C" {
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+ #include "IMB_colormanagement.h"
}
@@ -43,10 +44,10 @@ ViewerBaseOperation::ViewerBaseOperation() : NodeOperation()
this->setImageUser(NULL);
this->m_outputBuffer = NULL;
this->m_depthBuffer = NULL;
- this->m_outputBufferDisplay = NULL;
this->m_active = false;
- this->m_doColorManagement = true;
this->m_doDepthBuffer = false;
+ this->m_viewSettings = NULL;
+ this->m_displaySettings = NULL;
}
void ViewerBaseOperation::initExecution()
@@ -60,7 +61,7 @@ void ViewerBaseOperation::initImage()
{
Image *anImage = this->m_image;
ImBuf *ibuf = BKE_image_acquire_ibuf(anImage, this->m_imageUser, &this->m_lock);
-
+
if (!ibuf) return;
BLI_lock_thread(LOCK_DRAW_IMAGE);
if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {
@@ -70,30 +71,44 @@ void ViewerBaseOperation::initImage()
IMB_freezbuffloatImBuf(ibuf);
ibuf->x = getWidth();
ibuf->y = getHeight();
- imb_addrectImBuf(ibuf);
imb_addrectfloatImBuf(ibuf);
anImage->ok = IMA_OK_LOADED;
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+
+ BLI_unlock_thread(LOCK_DRAW_IMAGE);
}
+
if (m_doDepthBuffer)
{
addzbuffloatImBuf(ibuf);
}
BLI_unlock_thread(LOCK_DRAW_IMAGE);
-
-
+
/* now we combine the input with ibuf */
this->m_outputBuffer = ibuf->rect_float;
- this->m_outputBufferDisplay = (unsigned char *)ibuf->rect;
+
+ /* needed for display buffer update
+ *
+ * no need to lock / reference the image buffer because it's seems
+ * to be the single place which changes buffers of viewer image
+ * which is this node
+ */
+ this->m_ibuf = ibuf;
+
if (m_doDepthBuffer)
{
this->m_depthBuffer = ibuf->zbuf_float;
}
-
+
BKE_image_release_ibuf(this->m_image, this->m_lock);
}
void ViewerBaseOperation:: updateImage(rcti *rect)
{
+ IMB_partial_display_buffer_update(this->m_ibuf, this->m_outputBuffer, NULL, getWidth(), 0, 0,
+ this->m_viewSettings, this->m_displaySettings,
+ rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+
WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL);
}
diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.h b/source/blender/compositor/operations/COM_ViewerBaseOperation.h
index d90eb343f6c..f7d479eb3b8 100644
--- a/source/blender/compositor/operations/COM_ViewerBaseOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.h
@@ -30,7 +30,6 @@ class ViewerBaseOperation : public NodeOperation {
protected:
float *m_outputBuffer;
float *m_depthBuffer;
- unsigned char *m_outputBufferDisplay;
Image *m_image;
ImageUser *m_imageUser;
void *m_lock;
@@ -38,9 +37,11 @@ protected:
float m_centerX;
float m_centerY;
OrderOfChunks m_chunkOrder;
- bool m_doColorManagement;
- bool m_doColorPredivide;
bool m_doDepthBuffer;
+ ImBuf *m_ibuf;
+
+ const ColorManagedViewSettings *m_viewSettings;
+ const ColorManagedDisplaySettings *m_displaySettings;
public:
bool isOutputOperation(bool rendering) const { return isActiveViewerOutput(); }
@@ -57,10 +58,10 @@ public:
float getCenterY() { return this->m_centerY; }
OrderOfChunks getChunkOrder() { return this->m_chunkOrder; }
const CompositorPriority getRenderPriority() const;
- void setColorManagement(bool doColorManagement) { this->m_doColorManagement = doColorManagement; }
- void setColorPredivide(bool doColorPredivide) { this->m_doColorPredivide = doColorPredivide; }
bool isViewerOperation() { return true; }
-
+
+ void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; }
+ void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; }
protected:
ViewerBaseOperation();
void updateImage(rcti *rect);
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index b85b86bddc3..576d5da4d74 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -72,7 +72,6 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
{
float *buffer = this->m_outputBuffer;
float *depthbuffer = this->m_depthBuffer;
- unsigned char *bufferDisplay = this->m_outputBufferDisplay;
if (!buffer) return;
const int x1 = rect->xmin;
const int y1 = rect->ymin;
@@ -82,7 +81,7 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
const int offsetadd4 = offsetadd * 4;
int offset = (y1 * this->getWidth() + x1);
int offset4 = offset * 4;
- float alpha[4], srgb[4], depth[4];
+ float alpha[4], depth[4];
int x;
int y;
bool breaked = false;
@@ -98,19 +97,6 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
this->m_depthInput->read(depth, x, y, COM_PS_NEAREST);
depthbuffer[offset] = depth[0];
}
- if (this->m_doColorManagement) {
- if (this->m_doColorPredivide) {
- linearrgb_to_srgb_predivide_v4(srgb, buffer + offset4);
- }
- else {
- linearrgb_to_srgb_v4(srgb, buffer + offset4);
- }
- }
- else {
- copy_v4_v4(srgb, buffer + offset4);
- }
-
- rgba_float_to_uchar(bufferDisplay + offset4, srgb);
offset ++;
offset4 += 4;