From ba68fea78b5fbbd45deeed0edaed46732a79cafe Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 11 Sep 2013 17:34:32 +0000 Subject: Fix #36700, z-depth not rendering properly at (n*256)+1 dimensions. The chunk indices for scheduling chunks based on a given area were calculated incorrectly. This caused chunks at the very border of the render (pixels 256..257) to be omitted, leading to incorrect values in the Z buffer of the test file, which in turn caused wrong normalization range and the resulting almost-white image. Also added a dedicated executePixel function for Z buffer to avoid any interpolation of Z values. --- .../compositor/operations/COM_RenderLayersProg.cpp | 21 +++++++++++++++++++++ .../compositor/operations/COM_RenderLayersProg.h | 2 +- .../operations/COM_WriteBufferOperation.cpp | 1 - 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'source/blender/compositor/operations') diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp index 8a32502982c..ea6ad86d92c 100644 --- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp @@ -234,6 +234,27 @@ RenderLayersDepthProg::RenderLayersDepthProg() : RenderLayersBaseProg(SCE_PASS_Z this->addOutputSocket(COM_DT_VALUE); } +void RenderLayersDepthProg::executePixel(float output[4], float x, float y, PixelSampler sampler) +{ + int ix = x; + int iy = y; + float *inputBuffer = this->getInputBuffer(); + + if (inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() || iy >= (int)this->getHeight() ) { + output[0] = 0.0f; + output[1] = 0.0f; + output[2] = 0.0f; + output[3] = 0.0f; + } + else { + unsigned int offset = (iy * this->getWidth() + ix); + output[0] = inputBuffer[offset]; + output[1] = 0.0f; + output[2] = 0.0f; + output[3] = 0.0f; + } +} + /* ******** Render Layers Diffuse Operation ******** */ RenderLayersDiffuseOperation::RenderLayersDiffuseOperation() : RenderLayersBaseProg(SCE_PASS_DIFFUSE, 3) diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.h b/source/blender/compositor/operations/COM_RenderLayersProg.h index 48aaa47cc50..04861174387 100644 --- a/source/blender/compositor/operations/COM_RenderLayersProg.h +++ b/source/blender/compositor/operations/COM_RenderLayersProg.h @@ -111,7 +111,6 @@ class RenderLayersAlphaProg : public RenderLayersBaseProg { public: RenderLayersAlphaProg(); void executePixel(float output[4], float x, float y, PixelSampler sampler); - }; class RenderLayersColorOperation : public RenderLayersBaseProg { @@ -127,6 +126,7 @@ public: class RenderLayersDepthProg : public RenderLayersBaseProg { public: RenderLayersDepthProg(); + void executePixel(float output[4], float x, float y, PixelSampler sampler); }; class RenderLayersDiffuseOperation : public RenderLayersBaseProg { diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index f18493dc334..cf462607936 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -75,7 +75,6 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber) for (x = x1; x < x2; x++) { this->m_input->read(&(buffer[offset4]), x, y, data); offset4 += COM_NUMBER_OF_CHANNELS; - } if (isBreaked()) { breaked = true; -- cgit v1.2.3