[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43742] branches/tile/source/blender/ compositor: displace node cleanup (using clamp) + simple displace glitch fix + not using protected variables
Dalai Felinto
dfelinto at gmail.com
Fri Jan 27 10:03:57 CET 2012
Revision: 43742
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43742
Author: dfelinto
Date: 2012-01-27 09:03:47 +0000 (Fri, 27 Jan 2012)
Log Message:
-----------
displace node cleanup (using clamp) + simple displace glitch fix + not using protected variables
Modified Paths:
--------------
branches/tile/source/blender/compositor/nodes/COM_DisplaceNode.cpp
branches/tile/source/blender/compositor/operations/COM_DisplaceOperation.cpp
branches/tile/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
Modified: branches/tile/source/blender/compositor/nodes/COM_DisplaceNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_DisplaceNode.cpp 2012-01-27 08:17:53 UTC (rev 43741)
+++ branches/tile/source/blender/compositor/nodes/COM_DisplaceNode.cpp 2012-01-27 09:03:47 UTC (rev 43742)
@@ -30,10 +30,10 @@
void DisplaceNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
{
NodeOperation *operation;
- if (context->getQuality() == COM_QUALITY_HIGH)
+ if (context->getQuality() == COM_QUALITY_LOW)
+ operation = new DisplaceSimpleOperation();
+ else
operation = new DisplaceOperation();
- else
- operation = new DisplaceSimpleOperation();
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
Modified: branches/tile/source/blender/compositor/operations/COM_DisplaceOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_DisplaceOperation.cpp 2012-01-27 08:17:53 UTC (rev 43741)
+++ branches/tile/source/blender/compositor/operations/COM_DisplaceOperation.cpp 2012-01-27 09:03:47 UTC (rev 43742)
@@ -21,6 +21,7 @@
#include "COM_DisplaceOperation.h"
#include "BLI_math.h"
+#include "BLI_utildefines.h"
DisplaceOperation::DisplaceOperation(): NodeOperation() {
this->addInputSocket(COM_DT_COLOR);
@@ -42,8 +43,8 @@
this->inputScaleXProgram = this->getInputSocketReader(2);
this->inputScaleYProgram = this->getInputSocketReader(3);
- width_x4 = this->width * 4;
- height_x4 = this->height * 4;
+ width_x4 = this->getWidth() * 4;
+ height_x4 = this->getHeight() * 4;
}
@@ -68,19 +69,13 @@
/* clamp x and y displacement to triple image resolution -
* to prevent hangs from huge values mistakenly plugged in eg. z buffers */
- xs = min(width_x4, max(-width_x4, xs));
- ys = min(height_x4, max(-height_x4, ys));
+ CLAMP(xs, -width_x4, width_x4);
+ CLAMP(ys, -height_x4, height_x4);
this->inputVectorProgram->read(inVector, x, y, inputBuffers);
p_dx = inVector[0] * xs;
p_dy = inVector[1] * ys;
- /* if no displacement, then just copy this pixel */
- if (fabsf(p_dx) < DISPLACE_EPSILON && fabsf(p_dy) < DISPLACE_EPSILON) {
- this->inputColorProgram->read(color, x, y, inputBuffers);
- return;
- }
-
/* displaced pixel in uv coords, for image sampling */
u = x - p_dx + 0.5f;
v = y - p_dy + 0.5f;
@@ -95,8 +90,8 @@
dxt = p_dx - d_dx;
dyt = p_dy - d_dy;
- dxt = signf(dxt)*maxf(fabsf(dxt), DISPLACE_EPSILON)/this->width;
- dyt = signf(dyt)*maxf(fabsf(dyt), DISPLACE_EPSILON)/this->height;
+ dxt = signf(dxt)*maxf(fabsf(dxt), DISPLACE_EPSILON)/this->getWidth();
+ dyt = signf(dyt)*maxf(fabsf(dyt), DISPLACE_EPSILON)/this->getHeight();
/* EWA filtering */
this->inputColorProgram->read(color, u, v, dxt, dyt, inputBuffers);
Modified: branches/tile/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp 2012-01-27 08:17:53 UTC (rev 43741)
+++ branches/tile/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp 2012-01-27 09:03:47 UTC (rev 43742)
@@ -21,6 +21,7 @@
#include "COM_DisplaceSimpleOperation.h"
#include "BLI_math.h"
+#include "BLI_utildefines.h"
DisplaceSimpleOperation::DisplaceSimpleOperation(): NodeOperation() {
this->addInputSocket(COM_DT_COLOR);
@@ -41,8 +42,8 @@
this->inputScaleXProgram = this->getInputSocketReader(2);
this->inputScaleYProgram = this->getInputSocketReader(3);
- width_x4 = this->width * 4;
- height_x4 = this->height * 4;
+ width_x4 = this->getWidth() * 4;
+ height_x4 = this->getHeight() * 4;
}
@@ -65,22 +66,19 @@
/* clamp x and y displacement to triple image resolution -
* to prevent hangs from huge values mistakenly plugged in eg. z buffers */
- xs = min(width_x4, max(-width_x4, xs));
- ys = min(height_x4, max(-height_x4, ys));
+ CLAMP(xs, -width_x4, width_x4);
+ CLAMP(ys, -height_x4, height_x4);
this->inputVectorProgram->read(inVector, x, y, inputBuffers);
p_dx = inVector[0] * xs;
p_dy = inVector[1] * ys;
- /* if no displacement, then just copy this pixel */
- if (fabsf(p_dx) < DISPLACE_EPSILON && fabsf(p_dy) < DISPLACE_EPSILON) {
- this->inputColorProgram->read(color, x, y, inputBuffers);
- return;
- }
-
/* displaced pixel in uv coords, for image sampling */
+ /* clamp nodes to avoid glitches */
u = x - p_dx + 0.5f;
v = y - p_dy + 0.5f;
+ CLAMP(u, 0.f, this->getWidth()-1.f);
+ CLAMP(v, 0.f, this->getHeight()-1.f);
this->inputColorProgram->read(color, u, v, inputBuffers);
}
More information about the Bf-blender-cvs
mailing list