[Bf-blender-cvs] [e5435b3] blender-tiles: Added SAMPLING to the Bokeh blur.
Jeroen Bakker
noreply at git.blender.org
Tue Jul 15 19:59:35 CEST 2014
Commit: e5435b3d17fa062ea5c5e86c14ff8064d2653b31
Author: Jeroen Bakker
Date: Tue Jul 15 19:58:49 2014 +0200
https://developer.blender.org/rBe5435b3d17fa062ea5c5e86c14ff8064d2653b31
Added SAMPLING to the Bokeh blur.
===================================================================
M source/blender/compositor/intern/COM_ExecutionSystem.cpp
M source/blender/compositor/intern/COM_MemoryBufferColor.h
M source/blender/compositor/intern/COM_MemoryBufferValue.h
M source/blender/compositor/intern/COM_MemoryBufferVector.h
M source/blender/compositor/intern/COM_Sampler.h
M source/blender/compositor/intern/COM_SocketReader.h
M source/blender/compositor/operations/COM_BokehBlurOperation.cpp
M source/blender/compositor/operations/COM_BokehBlurOperation.h
M source/blender/compositor/operations/COM_DilateErodeOperation.cpp
M source/blender/compositor/operations/COM_ReadBufferOperation.h
===================================================================
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
index 62c86ac..b82f47b 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
@@ -137,11 +137,15 @@ void ExecutionSystem::execute()
}
unsigned int index;
+ // First allocale all write buffers
for (index = 0; index < this->m_operations.size(); index++) {
NodeOperation *operation = this->m_operations[index];
- operation->setbNodeTree(this->m_context.getbNodeTree());
- operation->initExecution();
+ if (operation->isWriteBufferOperation()) {
+ operation->setbNodeTree(this->m_context.getbNodeTree());
+ operation->initExecution();
+ }
}
+ // Connect read buffers to their write buffers
for (index = 0; index < this->m_operations.size(); index++) {
NodeOperation *operation = this->m_operations[index];
if (operation->isReadBufferOperation()) {
@@ -149,6 +153,14 @@ void ExecutionSystem::execute()
readOperation->updateMemoryBuffer();
}
}
+ // initialize other operations
+ for (index = 0; index < this->m_operations.size(); index++) {
+ NodeOperation *operation = this->m_operations[index];
+ if (!operation->isWriteBufferOperation()) {
+ operation->setbNodeTree(this->m_context.getbNodeTree());
+ operation->initExecution();
+ }
+ }
for (index = 0; index < this->m_groups.size(); index++) {
ExecutionGroup *executionGroup = this->m_groups[index];
executionGroup->setChunksize(this->m_context.getChunksize());
diff --git a/source/blender/compositor/intern/COM_MemoryBufferColor.h b/source/blender/compositor/intern/COM_MemoryBufferColor.h
index b2b78a5..c7591fc 100644
--- a/source/blender/compositor/intern/COM_MemoryBufferColor.h
+++ b/source/blender/compositor/intern/COM_MemoryBufferColor.h
@@ -66,6 +66,10 @@ public:
MemoryBufferExtend extend_x = COM_MB_CLIP,
MemoryBufferExtend extend_y = COM_MB_CLIP);
+ SamplerNearestColor* get_sampler_nearest() {return this->m_sampler_nearest;}
+ SamplerNearestNoCheckColor* get_sampler_nocheck() {return this->m_sampler_nocheck;}
+ SamplerBilinearColor* get_sampler_bilinear() {return this->m_sampler_bilinear;}
+
void readEWA(float result[4], const float uv[2], const float derivatives[2][2], PixelSampler sampler);
MemoryBuffer *duplicate();
diff --git a/source/blender/compositor/intern/COM_MemoryBufferValue.h b/source/blender/compositor/intern/COM_MemoryBufferValue.h
index c40b3da..ef9ab3d 100644
--- a/source/blender/compositor/intern/COM_MemoryBufferValue.h
+++ b/source/blender/compositor/intern/COM_MemoryBufferValue.h
@@ -65,6 +65,10 @@ public:
MemoryBufferExtend extend_x = COM_MB_CLIP,
MemoryBufferExtend extend_y = COM_MB_CLIP);
+ SamplerNearestValue* get_sampler_nearest() {return this->m_sampler_nearest;}
+ SamplerNearestNoCheckValue* get_sampler_nocheck() {return this->m_sampler_nocheck;}
+ SamplerBilinearValue* get_sampler_bilinear() {return this->m_sampler_bilinear;}
+
float getMaximumValue() const;
MemoryBuffer *duplicate();
diff --git a/source/blender/compositor/intern/COM_MemoryBufferVector.h b/source/blender/compositor/intern/COM_MemoryBufferVector.h
index 14a501a..db1e623 100644
--- a/source/blender/compositor/intern/COM_MemoryBufferVector.h
+++ b/source/blender/compositor/intern/COM_MemoryBufferVector.h
@@ -65,6 +65,9 @@ public:
MemoryBufferExtend extend_x = COM_MB_CLIP,
MemoryBufferExtend extend_y = COM_MB_CLIP);
+ SamplerNearestVector* get_sampler_nearest() {return this->m_sampler_nearest;}
+ SamplerNearestNoCheckVector* get_sampler_nocheck() {return this->m_sampler_nocheck;}
+ SamplerBilinearVector* get_sampler_bilinear() {return this->m_sampler_bilinear;}
MemoryBuffer *duplicate();
friend class MemoryBuffer;
diff --git a/source/blender/compositor/intern/COM_Sampler.h b/source/blender/compositor/intern/COM_Sampler.h
index ea97861..5b6cd95 100644
--- a/source/blender/compositor/intern/COM_Sampler.h
+++ b/source/blender/compositor/intern/COM_Sampler.h
@@ -79,7 +79,7 @@ protected:
bool clip_y = (extend_y == COM_MB_CLIP && (y < 0 || y >= this->m_height));
if (clip_x || clip_y) {
/* clip result outside rect is zero */
- zero_v4(result);
+ result[0] = 0.0f;
}
else
{
@@ -93,13 +93,13 @@ protected:
bool clip_y = (extend_y == COM_MB_CLIP && (y < 0 || y >= this->m_height));
if (clip_x || clip_y) {
/* clip result outside rect is zero */
- zero_v4(result);
+ zero_v3(result);
}
else
{
this->wrap_pixel(x, y, extend_x, extend_y);
const int offset = (this->m_width * y + x) * COM_NUM_CHANNELS_VECTOR;
- result[0] = this->m_buffer[offset];
+ copy_v3_v3(result, &this->m_buffer[offset]);
}
}
inline void read_color(float *result, int x, int y, MemoryBufferExtend extend_x = COM_MB_CLIP, MemoryBufferExtend extend_y = COM_MB_CLIP) {
@@ -113,7 +113,7 @@ protected:
{
this->wrap_pixel(x, y, extend_x, extend_y);
const int offset = (this->m_width * y + x) * COM_NUM_CHANNELS_COLOR;
- result[0] = this->m_buffer[offset];
+ copy_v4_v4(result, &this->m_buffer[offset]);
}
}
diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h
index c996ef5..234bbb6 100644
--- a/source/blender/compositor/intern/COM_SocketReader.h
+++ b/source/blender/compositor/intern/COM_SocketReader.h
@@ -111,6 +111,7 @@ public:
inline const unsigned int getWidth() const { return this->m_width; }
inline const unsigned int getHeight() const { return this->m_height; }
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketReader")
#endif
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
index 22f6fc3..38bf1d1 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
@@ -63,6 +63,10 @@ void BokehBlurOperation::initExecution()
this->m_inputBokehProgram = getInputSocketReader(1);
this->m_inputBoundingBoxReader = getInputSocketReader(2);
+
+ this->m_bokeh_sampler = ((ReadBufferOperation*)getInputOperation(1))->get_sampler_nearest_color();
+ this->m_boundingbox_sampler = ((ReadBufferOperation*)getInputOperation(1))->get_sampler_nearest_value();
+
int width = this->m_inputBokehProgram->getWidth();
int height = this->m_inputBokehProgram->getHeight();
@@ -80,7 +84,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
float tempBoundingBox[4];
float bokeh[4];
- this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, COM_PS_NEAREST);
+ this->m_boundingbox_sampler->read(tempBoundingBox, x, y);
if (tempBoundingBox[0] > 0.0f) {
float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
@@ -118,7 +122,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
for (int nx = minx; nx < maxx; nx += step) {
float u = this->m_bokehMidX - (nx - x) * m;
float v = this->m_bokehMidY - (ny - y) * m;
- this->m_inputBokehProgram->readSampled(bokeh, u, v, COM_PS_NEAREST);
+ this->m_bokeh_sampler->read(bokeh, u, v);
madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]);
add_v4_v4(multiplier_accum, bokeh);
bufferindex += offsetadd;
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h
index d294482..8c61265 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h
@@ -25,12 +25,16 @@
#include "COM_NodeOperation.h"
#include "COM_QualityStepHelper.h"
+#include "COM_Sampler.h"
class BokehBlurOperation : public NodeOperation, public QualityStepHelper {
private:
SocketReader *m_inputProgram;
SocketReader *m_inputBokehProgram;
SocketReader *m_inputBoundingBoxReader;
+ SamplerNearestColor *m_bokeh_sampler;
+ SamplerNearestValue *m_boundingbox_sampler;
+
void updateSize();
float m_size;
bool m_sizeavailable;
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
index d5c6636..1030170 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
@@ -72,7 +72,8 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
const float inset = this->m_inset;
float mindist = rd * 2;
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ MemoryBufferValue *inputBuffer = (MemoryBufferValue *)data;
+ SamplerNearestValue *sampler = inputBuffer->get_sampler_nearest();
float *buffer = inputBuffer->getBuffer();
rcti *rect = inputBuffer->getRect();
const int minx = max(x - this->m_scope, rect->xmin);
@@ -82,18 +83,18 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
const int bufferWidth = BLI_rcti_size_x(rect);
int offset;
- inputBuffer->read(inputValue, x, y);
- if (inputValue[0] > sw) {
+ sampler->read(inputValue, x, y);
+ if (inputValue[0] > sw) {
for (int yi = miny; yi < maxy; yi++) {
const float dy = yi - y;
- offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
+ offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
for (int xi = minx; xi < maxx; xi++) {
if (buffer[offset] < sw) {
const float dx = xi - x;
const float dis = dx * dx + dy * dy;
mindist = min(mindist, dis);
}
- offset ++;
+ offset ++;
}
}
pixelvalue = -sqrtf(mindist);
@@ -101,15 +102,14 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
else {
for (int yi = miny; yi < maxy; yi++) {
const float dy = yi - y;
- offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
+ offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
for (int xi = minx; xi < maxx; xi++) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list