[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49701] trunk/blender/source/blender/ compositor: improvement to the DOF node, after blurring the radius buffer ( derived from the depth), overlay with the original so pixels in focus are not mixed with out of focus pixels .

Campbell Barton ideasman42 at gmail.com
Wed Aug 8 18:46:12 CEST 2012


Revision: 49701
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49701
Author:   campbellbarton
Date:     2012-08-08 16:46:12 +0000 (Wed, 08 Aug 2012)
Log Message:
-----------
improvement to the DOF node, after blurring the radius buffer (derived from the depth), overlay with the original so pixels in focus are not mixed with out of focus pixels.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/nodes/COM_DefocusNode.cpp
    trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h

Modified: trunk/blender/source/blender/compositor/nodes/COM_DefocusNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_DefocusNode.cpp	2012-08-08 16:44:16 UTC (rev 49700)
+++ trunk/blender/source/blender/compositor/nodes/COM_DefocusNode.cpp	2012-08-08 16:46:12 UTC (rev 49701)
@@ -73,11 +73,14 @@
 		this->getInputSocket(1)->relinkConnections(converter->getInputSocket(0), 1, graph);
 		graph->addOperation(converter);
 		
-		FastGaussianBlurValueOperation * blur = new FastGaussianBlurValueOperation();
+		FastGaussianBlurValueOperation *blur = new FastGaussianBlurValueOperation();
 		addLink(graph, converter->getOutputSocket(0), blur->getInputSocket(0));
 		graph->addOperation(blur);
 		radiusOperation = blur;
 		converter->setPostBlur(blur);
+
+		/* maintain close pixels so far Z values don't bleed into the foreground */
+		blur->setOverlay(FAST_GAUSS_OVERLAY_MIN);
 	}
 	
 	BokehImageOperation *bokeh = new BokehImageOperation();

Modified: trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp	2012-08-08 16:44:16 UTC (rev 49700)
+++ trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp	2012-08-08 16:46:12 UTC (rev 49701)
@@ -277,6 +277,28 @@
 		MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputprogram->initializeTileData(rect);
 		MemoryBuffer *copy = newBuf->duplicate();
 		FastGaussianBlurOperation::IIR_gauss(copy, this->m_sigma, 0, 3);
+
+		if (this->m_overlay == FAST_GAUSS_OVERLAY_MIN) {
+			float *src = newBuf->getBuffer();
+			float *dst = copy->getBuffer();
+			for (int i = copy->getWidth() * copy->getHeight() * COM_NUMBER_OF_CHANNELS; i != 0; i--, src++, dst++) {
+				if (*src < *dst) {
+					*dst = *src;
+				}
+			}
+		}
+		else if (this->m_overlay == FAST_GAUSS_OVERLAY_MAX) {
+			float *src = newBuf->getBuffer();
+			float *dst = copy->getBuffer();
+			for (int i = copy->getWidth() * copy->getHeight() * COM_NUMBER_OF_CHANNELS; i != 0; i--, src++, dst++) {
+				if (*src > *dst) {
+					*dst = *src;
+				}
+			}
+		}
+
+//		newBuf->
+
 		this->m_iirgaus = copy;
 	}
 	unlockMutex();

Modified: trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h	2012-08-08 16:44:16 UTC (rev 49700)
+++ trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h	2012-08-08 16:46:12 UTC (rev 49701)
@@ -42,11 +42,23 @@
 	void initExecution();
 };
 
+enum {
+	FAST_GAUSS_OVERLAY_MIN  = -1,
+	FAST_GAUSS_OVERLAY_NONE =  0,
+	FAST_GAUSS_OVERLAY_MAX  =  1
+};
+
 class FastGaussianBlurValueOperation : public NodeOperation {
 private:
 	float m_sigma;
 	MemoryBuffer *m_iirgaus;
 	SocketReader *m_inputprogram;
+
+	/**
+	 * -1: re-mix with darker
+	 *  0: do nothing
+	 *  1 re-mix with lighter */
+	int m_overlay;
 public:
 	FastGaussianBlurValueOperation();
 	bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
@@ -56,6 +68,9 @@
 	void deinitExecution();
 	void initExecution();
 	void setSigma(float sigma) { this->m_sigma = sigma; }
+
+	/* used for DOF blurring ZBuffer */
+	void setOverlay(int overlay) { this->m_overlay = overlay; }
 };
 
 #endif




More information about the Bf-blender-cvs mailing list