[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60049] trunk/blender/source/blender/ compositor: Fix #36700, z-depth not rendering properly at (n*256) +1 dimensions.

Lukas Toenne lukas.toenne at googlemail.com
Wed Sep 11 19:34:32 CEST 2013


Revision: 60049
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60049
Author:   lukastoenne
Date:     2013-09-11 17:34:32 +0000 (Wed, 11 Sep 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/intern/COM_ExecutionGroup.cpp
    trunk/blender/source/blender/compositor/operations/COM_RenderLayersProg.cpp
    trunk/blender/source/blender/compositor/operations/COM_RenderLayersProg.h
    trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.cpp

Modified: trunk/blender/source/blender/compositor/intern/COM_ExecutionGroup.cpp
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_ExecutionGroup.cpp	2013-09-11 15:14:22 UTC (rev 60048)
+++ trunk/blender/source/blender/compositor/intern/COM_ExecutionGroup.cpp	2013-09-11 17:34:32 UTC (rev 60049)
@@ -518,17 +518,15 @@
 	// find all chunks inside the rect
 	// determine minxchunk, minychunk, maxxchunk, maxychunk where x and y are chunknumbers
 
-	float chunkSizef = this->m_chunkSize;
-
 	int indexx, indexy;
-	int minxchunk = floor((area->xmin - this->m_viewerBorder.xmin) / chunkSizef);
-	int maxxchunk = ceil((area->xmax - 1) / chunkSizef);
-	int minychunk = floor((area->ymin - this->m_viewerBorder.ymin) / chunkSizef);
-	int maxychunk = ceil((area->ymax - 1) / chunkSizef);
-	minxchunk = max(minxchunk, 0);
-	minychunk = max(minychunk, 0);
-	maxxchunk = min(maxxchunk, (int)this->m_numberOfXChunks);
-	maxychunk = min(maxychunk, (int)this->m_numberOfYChunks);
+	int minxchunk = (area->xmin - m_viewerBorder.xmin) / m_chunkSize;
+	int maxxchunk = (area->xmax + m_chunkSize - 1) / m_chunkSize;
+	int minychunk = (area->ymin - m_viewerBorder.ymin) / m_chunkSize;
+	int maxychunk = (area->ymax + m_chunkSize - 1) / m_chunkSize;
+	minxchunk = max_ii(minxchunk, 0);
+	minychunk = max_ii(minychunk, 0);
+	maxxchunk = min_ii(maxxchunk, m_numberOfXChunks);
+	maxychunk = min_ii(maxychunk, m_numberOfYChunks);
 
 	bool result = true;
 	for (indexx = minxchunk; indexx < maxxchunk; indexx++) {

Modified: trunk/blender/source/blender/compositor/operations/COM_RenderLayersProg.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_RenderLayersProg.cpp	2013-09-11 15:14:22 UTC (rev 60048)
+++ trunk/blender/source/blender/compositor/operations/COM_RenderLayersProg.cpp	2013-09-11 17:34:32 UTC (rev 60049)
@@ -234,6 +234,27 @@
 	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)

Modified: trunk/blender/source/blender/compositor/operations/COM_RenderLayersProg.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_RenderLayersProg.h	2013-09-11 15:14:22 UTC (rev 60048)
+++ trunk/blender/source/blender/compositor/operations/COM_RenderLayersProg.h	2013-09-11 17:34:32 UTC (rev 60049)
@@ -111,7 +111,6 @@
 public:
 	RenderLayersAlphaProg();
 	void executePixel(float output[4], float x, float y, PixelSampler sampler);
-
 };
 
 class RenderLayersColorOperation : public RenderLayersBaseProg {
@@ -127,6 +126,7 @@
 class RenderLayersDepthProg : public RenderLayersBaseProg {
 public:
 	RenderLayersDepthProg();
+	void executePixel(float output[4], float x, float y, PixelSampler sampler);
 };
 
 class RenderLayersDiffuseOperation : public RenderLayersBaseProg {

Modified: trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.cpp	2013-09-11 15:14:22 UTC (rev 60048)
+++ trunk/blender/source/blender/compositor/operations/COM_WriteBufferOperation.cpp	2013-09-11 17:34:32 UTC (rev 60049)
@@ -75,7 +75,6 @@
 			for (x = x1; x < x2; x++) {
 				this->m_input->read(&(buffer[offset4]), x, y, data);
 				offset4 += COM_NUMBER_OF_CHANNELS;
-
 			}
 			if (isBreaked()) {
 				breaked = true;




More information about the Bf-blender-cvs mailing list