[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47864] trunk/blender/source/blender/ compositor: Fixed glares

Jeroen Bakker j.bakker at atmind.nl
Thu Jun 14 05:11:53 CEST 2012


Revision: 47864
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47864
Author:   jbakker
Date:     2012-06-14 03:11:36 +0000 (Thu, 14 Jun 2012)
Log Message:
-----------
Fixed glares

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/CMakeLists.txt
    trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.cpp
    trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.h
    trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp
    trunk/blender/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_GlareThresholdOperation.h

Added Paths:
-----------
    trunk/blender/source/blender/compositor/operations/COM_MixGlareOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_MixGlareOperation.h

Modified: trunk/blender/source/blender/compositor/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/compositor/CMakeLists.txt	2012-06-14 02:21:21 UTC (rev 47863)
+++ trunk/blender/source/blender/compositor/CMakeLists.txt	2012-06-14 03:11:36 UTC (rev 47864)
@@ -461,6 +461,8 @@
 	operations/COM_MixBaseOperation.cpp
 	operations/COM_MixBlendOperation.cpp
 	operations/COM_MixBlendOperation.h
+	operations/COM_MixGlareOperation.cpp
+	operations/COM_MixGlareOperation.h
 	operations/COM_MixAddOperation.h
 	operations/COM_MixAddOperation.cpp
 	operations/COM_MixMultiplyOperation.h

Modified: trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.cpp
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.cpp	2012-06-14 02:21:21 UTC (rev 47863)
+++ trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.cpp	2012-06-14 03:11:36 UTC (rev 47864)
@@ -141,6 +141,16 @@
 	}
 }
 
+void MemoryBuffer::addPixel(int x, int y, const float color[4])
+{
+	if (x >= this->rect.xmin && x < this->rect.xmax &&
+	    y >= this->rect.ymin && y < this->rect.ymax)
+	{
+		const int offset = (this->chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS;
+		add_v4_v4(&this->buffer[offset], color);
+	}
+}
+
 void MemoryBuffer::readCubic(float result[4], float x, float y)
 {
 	int x1 = floor(x);

Modified: trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.h
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.h	2012-06-14 02:21:21 UTC (rev 47863)
+++ trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.h	2012-06-14 03:11:36 UTC (rev 47864)
@@ -126,6 +126,7 @@
 	
 	void read(float result[4], int x, int y);
 	void writePixel(int x, int y, const float color[4]);
+	void addPixel(int x, int y, const float color[4]);
 	void readCubic(float result[4], float x, float y);
 	void readEWA(float result[4], float fx, float fy, float dx, float dy);
 	

Modified: trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp	2012-06-14 02:21:21 UTC (rev 47863)
+++ trunk/blender/source/blender/compositor/nodes/COM_GlareNode.cpp	2012-06-14 03:11:36 UTC (rev 47864)
@@ -26,7 +26,7 @@
 #include "COM_GlareSimpleStarOperation.h"
 #include "COM_GlareStreaksOperation.h"
 #include "COM_SetValueOperation.h"
-#include "COM_MixBlendOperation.h"
+#include "COM_MixGlareOperation.h"
 #include "COM_FastGaussianBlurOperation.h"
 #include "COM_GlareGhostOperation.h"
 #include "COM_GlareFogGlowOperation.h"
@@ -40,109 +40,44 @@
 	bNode *node = this->getbNode();
 	NodeGlare *glare = (NodeGlare*)node->storage;
 	
+	GlareBaseOperation * glareoperation = NULL;
+	
 	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);
-		}
+		glareoperation = new GlareGhostOperation();
+		break;
 	case 2: // streaks
-		{
-			GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
-			GlareStreaksOperation * glareoperation = new GlareStreaksOperation();
-			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);
-		}	
+		glareoperation = new GlareStreaksOperation();
 		break;
 	case 1: // fog glow
-		{
-			GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
-			GlareFogGlowOperation * glareoperation = new GlareFogGlowOperation();
-			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);
-		}
+		glareoperation = new GlareFogGlowOperation();
 		break;
-		
 	case 0: // simple star
-		{
-			GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
-			GlareSimpleStarOperation * glareoperation = new GlareSimpleStarOperation();
-			SetValueOperation * mixvalueoperation = new SetValueOperation();
-			MixBlendOperation * mixoperation = new MixBlendOperation();
+		glareoperation = new GlareSimpleStarOperation();
+		break;
+	}
+	GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
+	SetValueOperation * mixvalueoperation = new SetValueOperation();
+	MixGlareOperation * mixoperation = new MixGlareOperation();
+	mixoperation->getInputSocket(2)->setResizeMode(COM_SC_FIT);
 
-			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());
+	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);
+	thresholdOperation->setGlareSettings(glare);
+	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);
-		}
-		break;
-	}
+	system->addOperation(glareoperation);
+	system->addOperation(thresholdOperation);
+	system->addOperation(mixvalueoperation);
+	system->addOperation(mixoperation);
+	
 }

Modified: trunk/blender/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp	2012-06-14 02:21:21 UTC (rev 47863)
+++ trunk/blender/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp	2012-06-14 03:11:36 UTC (rev 47864)
@@ -322,7 +322,7 @@
 				memset(data2, 0, w2*h2*sizeof(fREAL));
 				for (y=0; y<ybsz; y++) {
 					int yy = ybl*ybsz + y;
-					if (yy >= kernelHeight) continue;
+					if (yy >= imageHeight) continue;
 					fp = &data2[y*w2];
 					colp = (fRGB*)&imageBuffer[yy*imageWidth*COM_NUMBER_OF_CHANNELS];
 					for (x=0; x<xbsz; x++) {

Modified: trunk/blender/source/blender/compositor/operations/COM_GlareGhostOperation.cpp

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list