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:
authorJeroen Bakker <j.bakker@atmind.nl>2012-07-29 19:06:50 +0400
committerJeroen Bakker <j.bakker@atmind.nl>2012-07-29 19:06:50 +0400
commit93ff6f6dff73cf24e591dd2678ee601495714dc7 (patch)
treefb91d285b1400d26e36ad4d190aa87009c19d6a1 /source/blender/compositor/operations/COM_ViewerOperation.cpp
parent4ef8f3f537c7d3c10307cd7e6e1f01d644176914 (diff)
Support for depth buffers in compositor and viewer node
Support for only alpha images in compositor and viewer node
Diffstat (limited to 'source/blender/compositor/operations/COM_ViewerOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index f7c2ff93b3e..fac90ba2a9e 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -43,9 +43,11 @@ ViewerOperation::ViewerOperation() : ViewerBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
this->m_imageInput = NULL;
this->m_alphaInput = NULL;
+ this->m_depthInput = NULL;
}
void ViewerOperation::initExecution()
@@ -53,6 +55,8 @@ void ViewerOperation::initExecution()
// When initializing the tree during initial load the width and height can be zero.
this->m_imageInput = getInputSocketReader(0);
this->m_alphaInput = getInputSocketReader(1);
+ this->m_depthInput = getInputSocketReader(2);
+ this->m_doDepthBuffer = (this->m_depthInput != NULL);
ViewerBaseOperation::initExecution();
}
@@ -60,6 +64,7 @@ void ViewerOperation::deinitExecution()
{
this->m_imageInput = NULL;
this->m_alphaInput = NULL;
+ this->m_depthInput = NULL;
ViewerBaseOperation::deinitExecution();
}
@@ -67,47 +72,55 @@ void ViewerOperation::deinitExecution()
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;
const int x2 = rect->xmax;
const int y2 = rect->ymax;
- const int offsetadd = (this->getWidth() - (x2 - x1)) * 4;
- int offset = (y1 * this->getWidth() + x1) * 4;
- float alpha[4], srgb[4];
+ const int offsetadd = (this->getWidth() - (x2 - x1));
+ const int offsetadd4 = offsetadd * 4;
+ int offset = (y1 * this->getWidth() + x1);
+ int offset4 = offset * 4;
+ float alpha[4], srgb[4], depth[4];
int x;
int y;
bool breaked = false;
for (y = y1; y < y2 && (!breaked); y++) {
for (x = x1; x < x2; x++) {
- this->m_imageInput->read(&(buffer[offset]), x, y, COM_PS_NEAREST);
+ this->m_imageInput->read(&(buffer[offset4]), x, y, COM_PS_NEAREST);
if (this->m_alphaInput != NULL) {
this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST);
- buffer[offset + 3] = alpha[0];
+ buffer[offset4 + 3] = alpha[0];
}
+ if (m_depthInput) {
+ 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 + offset);
+ linearrgb_to_srgb_predivide_v4(srgb, buffer + offset4);
}
else {
- linearrgb_to_srgb_v4(srgb, buffer + offset);
+ linearrgb_to_srgb_v4(srgb, buffer + offset4);
}
}
else {
- copy_v4_v4(srgb, buffer + offset);
+ copy_v4_v4(srgb, buffer + offset4);
}
- rgba_float_to_uchar(bufferDisplay + offset, srgb);
+ rgba_float_to_uchar(bufferDisplay + offset4, srgb);
- offset += 4;
+ offset ++;
+ offset4 += 4;
}
if (isBreaked()) {
breaked = true;
}
-
offset += offsetadd;
+ offset4 += offsetadd4;
}
updateImage(rect);
}