[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47276] trunk/blender/source/blender/ compositor: Fix for [#31602] Node Glare: Ghosts effect
Jeroen Bakker
j.bakker at atmind.nl
Thu May 31 15:05:00 CEST 2012
Revision: 47276
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47276
Author: jbakker
Date: 2012-05-31 13:05:00 +0000 (Thu, 31 May 2012)
Log Message:
-----------
Fix for [#31602] Node Glare: Ghosts effect
Modified Paths:
--------------
trunk/blender/source/blender/compositor/CMakeLists.txt
trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp
trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
trunk/blender/source/blender/compositor/operations/COM_GlareBaseOperation.h
Added Paths:
-----------
trunk/blender/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_GlareGhostOperation.h
Removed Paths:
-------------
trunk/blender/source/blender/compositor/operations/COM_LensGhostOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_LensGhostOperation.h
trunk/blender/source/blender/compositor/operations/COM_LensGlowImageOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_LensGlowImageOperation.h
trunk/blender/source/blender/compositor/operations/COM_LensGlowOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_LensGlowOperation.h
Modified: trunk/blender/source/blender/compositor/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/compositor/CMakeLists.txt 2012-05-31 12:24:06 UTC (rev 47275)
+++ trunk/blender/source/blender/compositor/CMakeLists.txt 2012-05-31 13:05:00 UTC (rev 47276)
@@ -187,10 +187,6 @@
operations/COM_CropOperation.cpp
operations/COM_CropOperation.h
- operations/COM_LensGlowOperation.cpp
- operations/COM_LensGlowOperation.h
- operations/COM_LensGhostOperation.cpp
- operations/COM_LensGhostOperation.h
nodes/COM_TransformNode.cpp
nodes/COM_TransformNode.h
nodes/COM_Stabilize2dNode.cpp
@@ -374,16 +370,14 @@
operations/COM_RenderLayersCyclesOperation.cpp
operations/COM_RenderLayersCyclesOperation.h
-operations/COM_ImageOperation.cpp
-operations/COM_ImageOperation.h
-operations/COM_MultilayerImageOperation.cpp
-operations/COM_MultilayerImageOperation.h
-operations/COM_TextureOperation.cpp
-operations/COM_TextureOperation.h
-operations/COM_BokehImageOperation.cpp
-operations/COM_BokehImageOperation.h
-operations/COM_LensGlowImageOperation.cpp
-operations/COM_LensGlowImageOperation.h
+ operations/COM_ImageOperation.cpp
+ operations/COM_ImageOperation.h
+ operations/COM_MultilayerImageOperation.cpp
+ operations/COM_MultilayerImageOperation.h
+ operations/COM_TextureOperation.cpp
+ operations/COM_TextureOperation.h
+ operations/COM_BokehImageOperation.cpp
+ operations/COM_BokehImageOperation.h
operations/COM_SocketProxyOperation.h
@@ -575,6 +569,8 @@
operations/COM_GlareSimpleStarOperation.h
operations/COM_GlareStreaksOperation.cpp
operations/COM_GlareStreaksOperation.h
+ operations/COM_GlareGhostOperation.cpp
+ operations/COM_GlareGhostOperation.h
operations/COM_SetSamplerOperation.cpp
operations/COM_SetSamplerOperation.h
Modified: trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp 2012-05-31 12:24:06 UTC (rev 47275)
+++ trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp 2012-05-31 13:05:00 UTC (rev 47276)
@@ -29,6 +29,7 @@
#include "COM_SetValueOperation.h"
#include "COM_MixBlendOperation.h"
#include "COM_FastGaussianBlurOperation.h"
+#include "COM_GlareGhostOperation.h"
GlareNode::GlareNode(bNode *editorNode): Node(editorNode)
{
@@ -42,6 +43,30 @@
switch (glare->type) {
default:
+ case 3:
+ {
+ GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
+ GlareGhostOperation * glareoperation = new GlareGhostOperation();
+ SetValueOperation * mixvalueoperation = new SetValueOperation();
+ MixBlendOperation * mixoperation = new MixBlendOperation();
+
+ this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), 0, system);
+ addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
+ addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
+ addLink(system, glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
+ addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
+ this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
+
+ thresholdOperation->setThreshold(glare->threshold);
+ glareoperation->setGlareSettings(glare);
+ mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
+ mixoperation->setResolutionInputSocketIndex(1);
+
+ system->addOperation(glareoperation);
+ system->addOperation(thresholdOperation);
+ system->addOperation(mixvalueoperation);
+ system->addOperation(mixoperation);
+ }
case 2: // streaks
{
GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
Modified: trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h 2012-05-31 12:24:06 UTC (rev 47275)
+++ trunk/blender/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h 2012-05-31 13:05:00 UTC (rev 47276)
@@ -36,7 +36,7 @@
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
- void IIR_gauss(MemoryBuffer *src, float sigma, int channel, int xy);
+ static void IIR_gauss(MemoryBuffer *src, float sigma, int channel, int xy);
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data);
Modified: trunk/blender/source/blender/compositor/operations/COM_GlareBaseOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_GlareBaseOperation.h 2012-05-31 12:24:06 UTC (rev 47275)
+++ trunk/blender/source/blender/compositor/operations/COM_GlareBaseOperation.h 2012-05-31 13:05:00 UTC (rev 47276)
@@ -25,6 +25,36 @@
#include "COM_NodeOperation.h"
#include "DNA_node_types.h"
+
+/* utility functions used by glare, tonemap and lens distortion */
+/* soms macros for color handling */
+typedef float fRGB[4];
+/* clear color */
+#define fRGB_clear(c) { c[0]=c[1]=c[2]=0.f; } (void)0
+/* copy c2 to c1 */
+#define fRGB_copy(c1, c2) { c1[0]=c2[0]; c1[1]=c2[1]; c1[2]=c2[2]; c1[3]=c2[3]; } (void)0
+/* add c2 to c1 */
+#define fRGB_add(c1, c2) { c1[0]+=c2[0]; c1[1]+=c2[1]; c1[2]+=c2[2]; } (void)0
+/* subtract c2 from c1 */
+#define fRGB_sub(c1, c2) { c1[0]-=c2[0]; c1[1]-=c2[1]; c1[2]-=c2[2]; } (void)0
+/* multiply c by float value s */
+#define fRGB_mult(c, s) { c[0]*=s; c[1]*=s; c[2]*=s; } (void)0
+/* multiply c2 by s and add to c1 */
+#define fRGB_madd(c1, c2, s) { c1[0]+=c2[0]*s; c1[1]+=c2[1]*s; c1[2]+=c2[2]*s; } (void)0
+/* multiply c2 by color c1 */
+#define fRGB_colormult(c, cs) { c[0]*=cs[0]; c[1]*=cs[1]; c[2]*=cs[2]; } (void)0
+/* multiply c2 by color c3 and add to c1 */
+#define fRGB_colormadd(c1, c2, c3) { c1[0]+=c2[0]*c3[0]; c1[1]+=c2[1]*c3[1]; c1[2]+=c2[2]*c3[2]; } (void)0
+/* multiply c2 by color rgb, rgb as separate arguments */
+#define fRGB_rgbmult(c, r, g, b) { c[0]*=(r); c[1]*=(g); c[2]*=(b); } (void)0
+/* swap colors c1 & c2 */
+#define fRGB_swap(c1, c2) { float _t=c1[0]; c1[0]=c2[0]; c2[0]=_t;\
+ _t=c1[1]; c1[1]=c2[1]; c2[1]=_t;\
+ _t=c1[2]; c1[2]=c2[2]; c2[2]=_t;\
+ _t=c1[3]; c1[3]=c2[3]; c3[3]=_t;\
+ } (void)0
+
+
class GlareBaseOperation : public NodeOperation {
private:
/**
Added: trunk/blender/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_GlareGhostOperation.cpp (rev 0)
+++ trunk/blender/source/blender/compositor/operations/COM_GlareGhostOperation.cpp 2012-05-31 13:05:00 UTC (rev 47276)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GlareGhostOperation.h"
+#include "BLI_math.h"
+#include "COM_FastGaussianBlurOperation.h"
+
+static float smoothMask(float x, float y)
+{
+ float t;
+ x = 2.f*x - 1.f, y = 2.f*y - 1.f;
+ if ((t = 1.f - sqrtf(x*x + y*y)) <= 0.f) return 0.f;
+ return t;
+}
+
+
+void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
+{
+ const int qt = 1 << settings->quality;
+ const float s1 = 4.f/(float)qt, s2 = 2.f*s1;
+ int x, y, n, p, np;
+ fRGB c, tc, cm[64];
+ float sc, isc, u, v, sm, s, t, ofs, scalef[64];
+ const float cmo = 1.f - settings->colmod;
+
+ MemoryBuffer *gbuf = inputTile->duplicate();
+ MemoryBuffer *tbuf1 = inputTile->duplicate();
+
+ FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 0, 3);
+ FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 1, 3);
+ FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 2, 3);
+
+ MemoryBuffer *tbuf2 = tbuf1->duplicate();
+
+ FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 0, 3);
+ FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 1, 3);
+ FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 2, 3);
+
+ if (settings->iter & 1) ofs = 0.5f; else ofs = 0.f;
+ for (x=0; x<(settings->iter*4); x++) {
+ y = x & 3;
+ cm[x][0] = cm[x][1] = cm[x][2] = 1;
+ if (y==1) fRGB_rgbmult(cm[x], 1.f, cmo, cmo);
+ if (y==2) fRGB_rgbmult(cm[x], cmo, cmo, 1.f);
+ if (y==3) fRGB_rgbmult(cm[x], cmo, 1.f, cmo);
+ scalef[x] = 2.1f*(1.f-(x+ofs)/(float)(settings->iter*4));
+ if (x & 1) scalef[x] = -0.99f/scalef[x];
+ }
+
+ sc = 2.13;
+ isc = -0.97;
+ for (y=0; y<gbuf->getHeight(); y++) {
+ v = (float)(y+0.5f) / (float)gbuf->getHeight();
+ for (x=0; x<gbuf->getWidth(); x++) {
+ u = (float)(x+0.5f) / (float)gbuf->getWidth();
+ s = (u-0.5f)*sc + 0.5f, t = (v-0.5f)*sc + 0.5f;
+ tbuf1->read(c, s*gbuf->getWidth(), t*gbuf->getHeight());
+ sm = smoothMask(s, t);
+ fRGB_mult(c, sm);
+ s = (u-0.5f)*isc + 0.5f, t = (v-0.5f)*isc + 0.5f;
+ tbuf2->read(tc, s*gbuf->getWidth()-0.5f, t*gbuf->getHeight()-0.5f);
+ sm = smoothMask(s, t);
+ fRGB_madd(c, tc, sm);
+
+ gbuf->writePixel(x, y, c);
+ }
+ }
+
+ memset(tbuf1->getBuffer(), 0, tbuf1->getWidth()*tbuf1->getHeight()*COM_NUMBER_OF_CHANNELS*sizeof(float));
+ for (n=1; n<settings->iter; n++) {
+ for (y=0; y<gbuf->getHeight(); y++) {
+ v = (float)(y+0.5f) / (float)gbuf->getHeight();
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list