[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43175] branches/tile/source/blender/ compositor: Tile branch

Jeroen Bakker j.bakker at atmind.nl
Thu Jan 5 18:02:21 CET 2012


Revision: 43175
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43175
Author:   jbakker
Date:     2012-01-05 17:02:20 +0000 (Thu, 05 Jan 2012)
Log Message:
-----------
Tile branch
 * added the simple start (4star) glare operation
 * cleaned up the FogGlowImage operation.

In the trunk implementation there is an error in the formula when using the 'Quality' setting
low quality will create larger stars. In the new implementation all will be done in the high quality setting.

Modified Paths:
--------------
    branches/tile/source/blender/compositor/CMakeLists.txt
    branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.cpp
    branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.h
    branches/tile/source/blender/compositor/nodes/COM_GlareNode.cpp
    branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.h

Added Paths:
-----------
    branches/tile/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_GlareBaseOperation.h
    branches/tile/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h

Modified: branches/tile/source/blender/compositor/CMakeLists.txt
===================================================================
--- branches/tile/source/blender/compositor/CMakeLists.txt	2012-01-05 17:00:05 UTC (rev 43174)
+++ branches/tile/source/blender/compositor/CMakeLists.txt	2012-01-05 17:02:20 UTC (rev 43175)
@@ -464,6 +464,10 @@
 	operations/COM_FogGlowImageOperation.h
 	operations/COM_GlareThresholdOperation.cpp
 	operations/COM_GlareThresholdOperation.h
+	operations/COM_GlareBaseOperation.cpp
+	operations/COM_GlareBaseOperation.h
+	operations/COM_GlareSimpleStarOperation.cpp
+	operations/COM_GlareSimpleStarOperation.h
 
 
 #Convert operations

Modified: branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.cpp	2012-01-05 17:00:05 UTC (rev 43174)
+++ branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.cpp	2012-01-05 17:02:20 UTC (rev 43175)
@@ -59,6 +59,11 @@
     this->datatype = COM_DT_COLOR;
 	this->chunkWidth = this->rect.xmax - this->rect.xmin;
 }
+MemoryBuffer* MemoryBuffer::duplicate() {
+	MemoryBuffer *result = new MemoryBuffer(this->memoryProxy, &this->rect);
+	memcpy(result->buffer, this->buffer, this->determineBufferSize()*4*sizeof(float));
+	return result;
+}
 
 MemoryBuffer::~MemoryBuffer() {
     if (this->buffer) {
@@ -114,6 +119,16 @@
         result[3] = 0.0f;
     }
 }
+void MemoryBuffer::writePixel(int x, int y, float color[4]) {
+	if (x>=this->rect.xmin && x < this->rect.xmax &&
+			y>=this->rect.ymin && y < this->rect.ymax) {
+		int offset = (this->chunkWidth*y+x)*4;
+		this->buffer[offset] = color[0];
+		this->buffer[offset+1] = color[1];
+		this->buffer[offset+2] = color[2];
+		this->buffer[offset+3] = color[3];
+	}
+}
 
 void MemoryBuffer::readCubic(float* result, float x, float y) {
     int x1 = floor(x);

Modified: branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.h
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.h	2012-01-05 17:00:05 UTC (rev 43174)
+++ branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.h	2012-01-05 17:02:20 UTC (rev 43175)
@@ -175,6 +175,7 @@
     }
 
     void read(float* result, int x, int y);
+	void writePixel(int x, int y, float color[4]);
     void readCubic(float* result, float x, float y);
 	void readEWA(float *result, float fx, float fy, float dx, float dy);
 
@@ -220,6 +221,7 @@
 	  */
 	int getHeight() const;
 
+	MemoryBuffer* duplicate();
 private:
     unsigned int determineBufferSize();
 };

Modified: branches/tile/source/blender/compositor/nodes/COM_GlareNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_GlareNode.cpp	2012-01-05 17:00:05 UTC (rev 43174)
+++ branches/tile/source/blender/compositor/nodes/COM_GlareNode.cpp	2012-01-05 17:02:20 UTC (rev 43175)
@@ -25,6 +25,7 @@
 #include "COM_FogGlowImageOperation.h"
 #include "COM_BokehBlurOperation.h"
 #include "COM_GlareThresholdOperation.h"
+#include "COM_GlareSimpleStarOperation.h"
 #include "COM_SetValueOperation.h"
 #include "COM_MixBlendOperation.h"
 
@@ -36,37 +37,66 @@
 	NodeGlare* glare = (NodeGlare*)node->storage;
 	
 	switch (glare->type) {
+	
 	default:
 	case 1: // fog glow
-		GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
-		FogGlowImageOperation * kerneloperation = new FogGlowImageOperation();
-		BokehBlurOperation * bluroperation = new BokehBlurOperation();
-		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, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
-		addLink(system, bluroperation->getOutputSocket(), mixoperation->getInputSocket(2));
-		addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
+		{
+			GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
+			FogGlowImageOperation * kerneloperation = new FogGlowImageOperation();
+			BokehBlurOperation * bluroperation = new BokehBlurOperation();
+			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, 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);
+			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);
+			system->addOperation(mixoperation);
+		}
+		break;
+		
+	case 0: // simple star
+		{
+			GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
+			GlareSimpleStarOperation * glareoperation = new GlareSimpleStarOperation();
+			SetValueOperation * mixvalueoperation = new SetValueOperation();
+			MixBlendOperation * mixoperation = new MixBlendOperation();
 
-		thresholdOperation->setThreshold(glare->threshold);
-		bluroperation->setSize(0.003f*glare->size);
-		bluroperation->setQuality(context->getQuality());
-		valueoperation->setValue(1.0f);
-		mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
-		this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
+			this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), true, 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());
 
-		system->addOperation(bluroperation);
-		system->addOperation(kerneloperation);
-		system->addOperation(thresholdOperation);
-		system->addOperation(mixvalueoperation);
-		system->addOperation(valueoperation);
-		system->addOperation(mixoperation);
+			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);
+		}
 		break;
 	}
 }

Modified: branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp	2012-01-05 17:00:05 UTC (rev 43174)
+++ branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp	2012-01-05 17:02:20 UTC (rev 43175)
@@ -28,9 +28,6 @@
 FogGlowImageOperation::FogGlowImageOperation(): NodeOperation() {
 	this->addOutputSocket(COM_DT_COLOR);
 }
-void FogGlowImageOperation::initExecution() {
-}
-
 void FogGlowImageOperation::executePixel(float* color, float x, float y, MemoryBuffer *inputBuffers[]) {
 	const float cs_r = 1.f, cs_g = 1.f, cs_b = 1.f;
 
@@ -47,9 +44,6 @@
 	color[3] = 1.0f;
 }
 
-void FogGlowImageOperation::deinitExecution() {
-}
-
 void FogGlowImageOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
 	resolution[0] = 512;
 	resolution[1] = 512;

Modified: branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.h
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.h	2012-01-05 17:00:05 UTC (rev 43174)
+++ branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.h	2012-01-05 17:02:20 UTC (rev 43175)
@@ -26,11 +26,6 @@
 #include "DNA_lamp_types.h"
 
 class FogGlowImageOperation : public NodeOperation {
-private:
-	/**
-	  * @brief Cached reference to the inputProgram
-	  */
-	SocketReader * inputProgram;
 public:
 	FogGlowImageOperation();
 	
@@ -39,16 +34,6 @@
 	  */
 	void executePixel(float* color, float x, float y, MemoryBuffer *inputBuffers[]);
 	
-	/**
-	  * Initialize the execution
-	  */
-	void initExecution();
-	
-	/**
-	  * Deinitialize the execution
-	  */
-	void deinitExecution();
-	
 	void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
 };
 #endif

Added: branches/tile/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
===================================================================

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list