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:
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.cpp5
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp22
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.h15
3 files changed, 41 insertions, 1 deletions
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp
index 7354c4fcd65..c2bd8997525 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.cpp
+++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp
@@ -73,11 +73,14 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
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();
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index 7ef363f5c4a..a7b5b5de6b5 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -277,6 +277,28 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect)
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();
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
index 4560e1b25e3..32dc428c21c 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
@@ -42,11 +42,23 @@ public:
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 @@ public:
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