Revision: 46838
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46838
Author: jbakker
Date: 2012-05-21 10:20:30 +0000 (Mon, 21 May 2012)
Log Message:
-----------
Added switch in dilate/erode between old (Step) and new (Distance)
algorithm
Connected the Glare Fog Flow to use Fast Gaussian in stead of Bokeh blur
Modified Paths:
--------------
trunk/blender/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp
trunk/blender/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_DilateErodeOperation.h
trunk/blender/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
trunk/blender/source/blender/editors/space_node/drawnode.c
trunk/blender/source/blender/makesdna/DNA_node_types.h
trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
Modified: trunk/blender/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
2012-05-21 10:13:43 UTC (rev 46837)
+++ trunk/blender/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
2012-05-21 10:20:30 UTC (rev 46838)
@@ -33,16 +33,37 @@
void DilateErodeNode::convertToOperations(ExecutionSystem *graph,
CompositorContext * context)
{
+
bNode *editorNode = this->getbNode();
- DilateErodeOperation *operation = new DilateErodeOperation();
- operation->setDistance(editorNode->custom2);
- operation->setInset(2.0f);
+ if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) {
+ DilateErodeDistanceOperation *operation = new
DilateErodeDistanceOperation();
+ operation->setDistance(editorNode->custom2);
+ operation->setInset(editorNode->custom3);
+
+
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0));
-
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0));
-
- AntiAliasOperation * antiAlias = new AntiAliasOperation();
- addLink(graph, operation->getOutputSocket(),
antiAlias->getInputSocket(0));
-
this->getOutputSocket(0)->relinkConnections(antiAlias->getOutputSocket(0));
- graph->addOperation(operation);
- graph->addOperation(antiAlias);
+ if (editorNode->custom3 < 2.0f) {
+ AntiAliasOperation * antiAlias = new
AntiAliasOperation();
+ addLink(graph, operation->getOutputSocket(),
antiAlias->getInputSocket(0));
+
this->getOutputSocket(0)->relinkConnections(antiAlias->getOutputSocket(0));
+ graph->addOperation(antiAlias);
+ } else {
+
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ }
+ graph->addOperation(operation);
+ } else {
+ if (editorNode->custom2 > 0) {
+ DilateStepOperation * operation = new
DilateStepOperation();
+ operation->setIterations(editorNode->custom2);
+
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0));
+
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ } else {
+ ErodeStepOperation * operation = new
ErodeStepOperation();
+ operation->setIterations(-editorNode->custom2);
+
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0));
+
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ }
+ }
}
Modified: trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp
2012-05-21 10:13:43 UTC (rev 46837)
+++ trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp
2012-05-21 10:20:30 UTC (rev 46838)
@@ -23,12 +23,12 @@
#include "COM_GlareNode.h"
#include "DNA_node_types.h"
#include "COM_FogGlowImageOperation.h"
-#include "COM_BokehBlurOperation.h"
#include "COM_GlareThresholdOperation.h"
#include "COM_GlareSimpleStarOperation.h"
#include "COM_GlareStreaksOperation.h"
#include "COM_SetValueOperation.h"
#include "COM_MixBlendOperation.h"
+#include "COM_FastGaussianBlurOperation.h"
GlareNode::GlareNode(bNode *editorNode): Node(editorNode)
{
@@ -70,29 +70,31 @@
case 1: // fog glow
{
GlareThresholdOperation *thresholdOperation = new
GlareThresholdOperation();
- FogGlowImageOperation * kerneloperation = new
FogGlowImageOperation();
- BokehBlurOperation * bluroperation = new
BokehBlurOperation();
+ FastGaussianBlurOperation* bluroperation = new
FastGaussianBlurOperation();
SetValueOperation * valueoperation = new
SetValueOperation();
SetValueOperation * mixvalueoperation = new
SetValueOperation();
MixBlendOperation * mixoperation = new
MixBlendOperation();
mixoperation->setResolutionInputSocketIndex(1);
this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0),
true, 0, system);
addLink(system, thresholdOperation->getOutputSocket(),
bluroperation->getInputSocket(0));
- addLink(system, kerneloperation->getOutputSocket(),
bluroperation->getInputSocket(1));
- addLink(system, valueoperation->getOutputSocket(),
bluroperation->getInputSocket(2));
+ addLink(system, valueoperation->getOutputSocket(),
bluroperation->getInputSocket(1));
addLink(system, mixvalueoperation->getOutputSocket(),
mixoperation->getInputSocket(0));
addLink(system, bluroperation->getOutputSocket(),
mixoperation->getInputSocket(2));
addLink(system,
thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(),
mixoperation->getInputSocket(1));
thresholdOperation->setThreshold(glare->threshold);
- bluroperation->setSize(0.003f*glare->size);
+ NodeBlurData * data = new NodeBlurData();
+ data->relative = 0;
+ data->sizex = glare->size;
+ data->sizey = glare->size;
+ bluroperation->setData(data);
+ bluroperation->deleteDataWhenFinished();
bluroperation->setQuality(context->getQuality());
valueoperation->setValue(1.0f);
mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
system->addOperation(bluroperation);
- system->addOperation(kerneloperation);
system->addOperation(thresholdOperation);
system->addOperation(mixvalueoperation);
system->addOperation(valueoperation);
Modified:
trunk/blender/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
===================================================================
---
trunk/blender/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
2012-05-21 10:13:43 UTC (rev 46837)
+++
trunk/blender/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
2012-05-21 10:20:30 UTC (rev 46838)
@@ -23,7 +23,7 @@
#include "COM_DilateErodeOperation.h"
#include "BLI_math.h"
-DilateErodeOperation::DilateErodeOperation(): NodeOperation()
+DilateErodeDistanceOperation::DilateErodeDistanceOperation(): NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
@@ -33,7 +33,7 @@
this->_switch = 0.5f;
this->distance = 0.0f;
}
-void DilateErodeOperation::initExecution()
+void DilateErodeDistanceOperation::initExecution()
{
this->inputProgram = this->getInputSocketReader(0);
if (this->distance < 0.0f) {
@@ -52,13 +52,13 @@
}
}
-void *DilateErodeOperation::initializeTileData(rcti *rect, MemoryBuffer
**memoryBuffers)
+void *DilateErodeDistanceOperation::initializeTileData(rcti *rect,
MemoryBuffer **memoryBuffers)
{
void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers);
return buffer;
}
-void DilateErodeOperation::executePixel(float *color, int x, int y,
MemoryBuffer *inputBuffers[], void *data)
+void DilateErodeDistanceOperation::executePixel(float *color, int x, int y,
MemoryBuffer *inputBuffers[], void *data)
{
float inputValue[4];
const float sw = this->_switch;
@@ -141,12 +141,12 @@
}
}
-void DilateErodeOperation::deinitExecution()
+void DilateErodeDistanceOperation::deinitExecution()
{
this->inputProgram = NULL;
}
-bool DilateErodeOperation::determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation, rcti *output)
+bool DilateErodeDistanceOperation::determineDependingAreaOfInterest(rcti
*input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
@@ -157,3 +157,151 @@
return NodeOperation::determineDependingAreaOfInterest(&newInput,
readOperation, output);
}
+
+// Dilate step
+DilateStepOperation::DilateStepOperation(): NodeOperation()
+{
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->setComplex(true);
+ this->inputProgram = NULL;
+}
+void DilateStepOperation::initExecution()
+{
+ this->inputProgram = this->getInputSocketReader(0);
+ this->cached_buffer = NULL;
+ this->initMutex();
+}
+
+void *DilateStepOperation::initializeTileData(rcti *rect, MemoryBuffer
**memoryBuffers)
+{
+ if (this->cached_buffer != NULL) {
+ return this->cached_buffer;
+ }
+ BLI_mutex_lock(getMutex());
+ if (this->cached_buffer == NULL) {
+ MemoryBuffer *buffer =
(MemoryBuffer*)inputProgram->initializeTileData(NULL, memoryBuffers);
+ float *rectf = buffer->convertToValueBuffer();
+ int x, y, i;
+ float *p;
+ int bwidth = buffer->getWidth();
+ int bheight = buffer->getHeight();
+ for (i = 0 ; i < this->iterations ; i ++) {
+ for (y=0; y < bheight; y++) {
+ for (x=0; x < bwidth-1; x++) {
+ p = rectf + (bwidth*y + x);
+ *p = MAX2(*p, *(p + 1));
+ }
+ }
+
+ for (y=0; y < bheight; y++) {
+ for (x=bwidth-1; x >= 1; x--) {
+ p = rectf + (bwidth*y + x);
+ *p = MAX2(*p, *(p - 1));
+ }
+ }
+
+ for (x=0; x < bwidth; x++) {
+ for (y=0; y < bheight-1; y++) {
+ p = rectf + (bwidth*y + x);
+ *p = MAX2(*p, *(p + bwidth));
+ }
+ }
+
+ for (x=0; x < bwidth; x++) {
+ for (y=bheight-1; y >= 1; y--) {
+ p = rectf + (bwidth*y + x);
+ *p = MAX2(*p, *(p - bwidth));
+ }
+ }
+ }
+ this->cached_buffer = rectf;
+ }
+ BLI_mutex_unlock(getMutex());
+ return this->cached_buffer;
+}
+
+
+void DilateStepOperation::executePixel(float *color, int x, int y,
MemoryBuffer *inputBuffers[], void *data)
+{
+ color[0] = this->cached_buffer[y*this->getWidth()+x];
+}
+
+void DilateStepOperation::deinitExecution()
+{
+ this->inputProgram = NULL;
+ this->deinitMutex();
+ if (this->cached_buffer) {
+ delete cached_buffer;
+ this->cached_buffer = NULL;
+ }
+}
+
+bool DilateStepOperation::determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation, rcti *output)
+{
+ if (this->cached_buffer) {
+ return false;
+ } else {
+ rcti newInput;
+
+ newInput.xmax = getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = getHeight();
+ newInput.ymin = 0;
+
+ return
NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation,
output);
+ }
+}
+
+// Erode step
+ErodeStepOperation::ErodeStepOperation(): DilateStepOperation()
+{
+}
+
+void *ErodeStepOperation::initializeTileData(rcti *rect, MemoryBuffer
**memoryBuffers)
+{
+ if (this->cached_buffer != NULL) {
+ return this->cached_buffer;
+ }
+ BLI_mutex_lock(getMutex());
+ if (this->cached_buffer == NULL) {
+ MemoryBuffer *buffer =
(MemoryBuffer*)inputProgram->initializeTileData(NULL, memoryBuffers);
+ float *rectf = buffer->convertToValueBuffer();
+ int x, y, i;
+ float *p;
+ int bwidth = buffer->getWidth();
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs