From ac5a735e3fe9fe29e38e3a20c20da87b27feb112 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 12 Jun 2012 04:23:21 +0000 Subject: * FIX for - [#31777] Border Crop gives black - [#31768] Crash when connecting a Math node to a translate node in Tiles comp - [#31638] View node in new node compo system crashes when inside a group * make sure a very fast vignette can be made by using a EliipseMask + Fast Gaussian blur --- source/blender/compositor/COM_defines.h | 4 +-- .../compositor/intern/COM_CompositorContext.cpp | 1 + .../compositor/intern/COM_CompositorContext.h | 15 +++++++++ .../compositor/intern/COM_ExecutionGroup.cpp | 7 ++--- .../compositor/intern/COM_ExecutionSystem.cpp | 36 +++++++++++++++++----- .../intern/COM_ExecutionSystemHelper.cpp | 19 +++++++++--- .../compositor/intern/COM_ExecutionSystemHelper.h | 4 +-- source/blender/compositor/intern/COM_Node.cpp | 14 +++++---- source/blender/compositor/intern/COM_Node.h | 19 ++++++++++++ .../blender/compositor/intern/COM_NodeOperation.h | 14 ++++++++- .../blender/compositor/intern/COM_OutputSocket.cpp | 9 ++++-- source/blender/compositor/nodes/COM_GroupNode.cpp | 9 +++--- .../compositor/nodes/COM_SplitViewerNode.cpp | 2 +- source/blender/compositor/nodes/COM_ViewerNode.cpp | 2 +- .../operations/COM_BokehBlurOperation.cpp | 5 ++- .../operations/COM_BokehImageOperation.cpp | 2 +- .../operations/COM_CompositorOperation.cpp | 19 ++++++++++-- .../compositor/operations/COM_PreviewOperation.h | 2 ++ .../operations/COM_ReadBufferOperation.cpp | 8 +++++ .../operations/COM_ReadBufferOperation.h | 2 +- .../compositor/operations/COM_RotateOperation.cpp | 32 ++++++++++++------- .../compositor/operations/COM_RotateOperation.h | 3 ++ .../operations/COM_SetVectorOperation.cpp | 10 ++---- .../operations/COM_SocketProxyOperation.cpp | 4 ++- .../operations/COM_TranslateOperation.cpp | 8 ++--- .../compositor/operations/COM_TranslateOperation.h | 12 ++++++++ .../COM_VariableSizeBokehBlurOperation.cpp | 21 ++++++++----- .../operations/COM_WriteBufferOperation.cpp | 6 ++++ .../operations/COM_WriteBufferOperation.h | 1 + 29 files changed, 214 insertions(+), 76 deletions(-) diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h index f87265c50f5..1aa023bea3a 100644 --- a/source/blender/compositor/COM_defines.h +++ b/source/blender/compositor/COM_defines.h @@ -70,6 +70,7 @@ typedef enum CompositorPriority { // chunk size determination #define COM_PREVIEW_SIZE 140.0f //#define COM_OPENCL_ENABLED +//#define COM_DEBUG // workscheduler threading models /** @@ -106,7 +107,4 @@ typedef enum OrderOfChunks { #define COM_NUMBER_OF_CHANNELS 4 -#define COM_DEFAULT_RESOLUTION_WIDTH 640 -#define COM_DEFAULT_RESOLUTION_HEIGHT 480 - #endif diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp index 911de822f80..bb8e7d9606d 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cpp +++ b/source/blender/compositor/intern/COM_CompositorContext.cpp @@ -29,6 +29,7 @@ CompositorContext::CompositorContext() this->scene = NULL; this->quality = COM_QUALITY_HIGH; this->hasActiveOpenCLDevices = false; + this->activegNode = NULL; } const int CompositorContext::getFramenumber() const diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index 2889f43290e..8425030aec2 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -63,6 +63,11 @@ private: * @see ExecutionSystem */ bNodeTree *bnodetree; + + /** + * @brief activegNode the group node that is currently being edited. + */ + bNode *activegNode; /** * @brief does this system have active opencl devices? @@ -100,6 +105,16 @@ public: */ const bNodeTree * getbNodeTree() const {return this->bnodetree;} + /** + * @brief set the active groupnode of the context + */ + void setActivegNode(bNode *gnode) {this->activegNode = gnode;} + + /** + * @brief get the active groupnode of the context + */ + const bNode * getActivegNode() const {return this->activegNode;} + /** * @brief get the scene of the context */ diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 481b83c81a3..e46b4934217 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -184,11 +184,8 @@ void ExecutionGroup::deinitExecution() void ExecutionGroup::determineResolution(unsigned int resolution[]) { NodeOperation *operation = this->getOutputNodeOperation(); - unsigned int preferredResolution[2]; - preferredResolution[0] = 0; - preferredResolution[1] = 0; - operation->determineResolution(resolution, preferredResolution); - operation->setResolution(resolution); + resolution[0] = operation->getWidth(); + resolution[1] = operation->getHeight(); this->setResolution(resolution); } diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 8c0b37a0685..1056c6d3f65 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -41,7 +41,14 @@ ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering) { - this->context.setbNodeTree(editingtree); + context.setbNodeTree(editingtree); + bNode* gnode; + for (gnode = (bNode*)editingtree->nodes.first ; gnode ; gnode = (bNode*)gnode->next) { + if (gnode->type == NODE_GROUP && gnode->typeinfo->group_edit_get(gnode)) { + context.setActivegNode(gnode); + break; + } + } /* initialize the CompositorContext */ if (rendering) { @@ -55,25 +62,25 @@ ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering) Node *mainOutputNode=NULL; - mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree); + mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL); if (mainOutputNode) { context.setScene((Scene*)mainOutputNode->getbNode()->id); this->convertToOperations(); this->groupOperations(); /* group operations in ExecutionGroups */ - vector executionGroups; - this->findOutputExecutionGroup(&executionGroups); unsigned int index; unsigned int resolution[2]; - for (index = 0 ; index < executionGroups.size(); index ++) { + for (index = 0 ; index < this->groups.size(); index ++) { resolution[0]=0; resolution[1]=0; - ExecutionGroup *executionGroup = executionGroups[index]; + ExecutionGroup *executionGroup = groups[index]; executionGroup->determineResolution(resolution); } } - if (G.f & G_DEBUG) ExecutionSystemHelper::debugDump(this); +#ifdef COM_DEBUG + ExecutionSystemHelper::debugDump(this); +#endif } ExecutionSystem::~ExecutionSystem() @@ -180,11 +187,13 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) writeoperation->setbNodeTree(this->getContext().getbNodeTree()); this->addOperation(writeoperation); ExecutionSystemHelper::addLink(this->getConnections(), fromsocket, writeoperation->getInputSocket(0)); + writeoperation->readResolutionFromInputSocket(); } ReadBufferOperation *readoperation = new ReadBufferOperation(); readoperation->setMemoryProxy(writeoperation->getMemoryProxy()); connection->setFromSocket(readoperation->getOutputSocket()); readoperation->getOutputSocket()->addConnection(connection); + readoperation->readResolutionFromWriteBuffer(); this->addOperation(readoperation); } } @@ -207,9 +216,11 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) readoperation->setMemoryProxy(writeOperation->getMemoryProxy()); connection->setFromSocket(readoperation->getOutputSocket()); readoperation->getOutputSocket()->addConnection(connection); + readoperation->readResolutionFromWriteBuffer(); this->addOperation(readoperation); } ExecutionSystemHelper::addLink(this->getConnections(), outputsocket, writeOperation->getInputSocket(0)); + writeOperation->readResolutionFromInputSocket(); } } @@ -237,7 +248,16 @@ void ExecutionSystem::convertToOperations() // determine all resolutions of the operations (Width/Height) for (index = 0 ; index < this->operations.size(); index ++) { NodeOperation *operation = this->operations[index]; - if (operation->isOutputOperation(context.isRendering())) { + if (operation->isOutputOperation(context.isRendering()) && !operation->isPreviewOperation()) { + unsigned int resolution[2] = {0,0}; + unsigned int preferredResolution[2] = {0,0}; + operation->determineResolution(resolution, preferredResolution); + operation->setResolution(resolution); + } + } + for (index = 0 ; index < this->operations.size(); index ++) { + NodeOperation *operation = this->operations[index]; + if (operation->isOutputOperation(context.isRendering()) && operation->isPreviewOperation()) { unsigned int resolution[2] = {0,0}; unsigned int preferredResolution[2] = {0,0}; operation->determineResolution(resolution, preferredResolution); diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp index 67554cd464b..75be8df74de 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp @@ -35,16 +35,20 @@ #include "COM_GroupNode.h" #include "COM_WriteBufferOperation.h" #include "COM_ReadBufferOperation.h" +#include "COM_ViewerBaseOperation.h" -Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree) +Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree * tree, bNode *groupnode) { vector& nodes = system.getNodes(); vector& links = system.getConnections(); Node *mainnode = NULL; + const bNode * activeGroupNode = system.getContext().getActivegNode(); + bool isActiveGroup = activeGroupNode == groupnode; + /* add all nodes of the tree to the node list */ bNode *node = (bNode*)tree->nodes.first; while (node != NULL) { - Node *execnode = addNode(nodes, node); + Node *execnode = addNode(nodes, node, isActiveGroup); if (node->type == CMP_NODE_COMPOSITE) { mainnode = execnode; } @@ -77,11 +81,12 @@ void ExecutionSystemHelper::addNode(vector& nodes, Node *node) nodes.push_back(node); } -Node *ExecutionSystemHelper::addNode(vector& nodes, bNode *bNode) +Node *ExecutionSystemHelper::addNode(vector& nodes, bNode *bNode, bool inActiveGroup) { Converter converter; Node * node; node = converter.convert(bNode); + node->setIsInActiveGroup(inActiveGroup); if (node != NULL) { addNode(nodes, node); return node; @@ -232,7 +237,12 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system) printf("|"); } if (operation->isViewerOperation()) { - printf("Viewer"); + ViewerBaseOperation * viewer = (ViewerBaseOperation*)operation; + if (viewer->isActiveViewerOutput()) { + printf("Active viewer"); + } else { + printf("Viewer"); + } } else if (operation->isOutputOperation(system->getContext().isRendering())) { printf("Output"); @@ -249,6 +259,7 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system) else { printf("O_%p", operation); } + printf(" (%d,%d)", operation->getWidth(), operation->getHeight()); tot2 = operation->getNumberOfOutputSockets(); if (tot2 != 0) { printf("|"); diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h index a72e269115e..9321cb571e8 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h @@ -48,7 +48,7 @@ public: * @param tree bNodeTree to add * @return Node representing the "Compositor node" of the maintree. or NULL when a subtree is added */ - static Node *addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree * tree); + static Node *addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree* tree, bNode *groupnode); /** * @brief add an editor node to the system. @@ -58,7 +58,7 @@ public: * @param bNode node to add * @return Node that represents the bNode or null when not able to convert. */ - static Node *addNode(vector& nodes, bNode *bNode); + static Node *addNode(vector& nodes, bNode *bNode, bool isInActiveGroup); /** * @brief Add a Node to a list diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp index 264725b4b2c..2324eacd26c 100644 --- a/source/blender/compositor/intern/COM_Node.cpp +++ b/source/blender/compositor/intern/COM_Node.cpp @@ -85,16 +85,18 @@ void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket) { - PreviewOperation *operation = new PreviewOperation(); - system->addOperation(operation); - operation->setbNode(this->getbNode()); - operation->setbNodeTree(system->getContext().getbNodeTree()); - this->addLink(system, outputSocket, operation->getInputSocket(0)); + if (this->isInActiveGroup()) { + PreviewOperation *operation = new PreviewOperation(); + system->addOperation(operation); + operation->setbNode(this->getbNode()); + operation->setbNodeTree(system->getContext().getbNodeTree()); + this->addLink(system, outputSocket, operation->getInputSocket(0)); + } } void Node::addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket) { - if (inputSocket->isConnected()) { + if (inputSocket->isConnected() && this->isInActiveGroup()) { OutputSocket *outputsocket = inputSocket->getConnection()->getFromSocket(); this->addPreviewOperation(system, outputsocket); } diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h index 23744adf642..0546062f790 100644 --- a/source/blender/compositor/intern/COM_Node.h +++ b/source/blender/compositor/intern/COM_Node.h @@ -52,6 +52,11 @@ private: */ bNode *editorNode; + /** + * @brief Is this node part of the active group + */ + bool inActiveGroup; + public: Node(bNode *editorNode, bool create_sockets=true); @@ -60,6 +65,20 @@ public: */ bNode *getbNode(); + /** + * @brief Is this node in the active group (the group that is being edited) + * @param isInActiveGroup + */ + void setIsInActiveGroup(bool isInActiveGroup) {this->inActiveGroup = isInActiveGroup; } + + /** + * @brief Is this node part of the active group + * the active group is the group that is currently being edited. When no group is edited, + * the active group will be the main tree (all nodes that are not part of a group will be active) + * @return bool [false:true] + */ + inline bool isInActiveGroup() {return this->inActiveGroup;} + /** * @brief convert node to operation * diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index 2219907b0c8..db1fdda0bcf 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -160,11 +160,22 @@ public: virtual void deinitExecution(); void deinitMutex(); + bool isResolutionSet() { + return this->width != 0 && height != 0; + } + /** * @brief set the resolution * @param resolution the resolution to set */ - void setResolution(unsigned int resolution[]) {this->width = resolution[0];this->height = resolution[1];} + void setResolution(unsigned int resolution[]) { + if (!isResolutionSet()) { + this->width = resolution[0]; + this->height = resolution[1]; + } + } + + void getConnectedInputSockets(vector *sockets); /** @@ -221,6 +232,7 @@ public: bool isOpenCL() { return this->openCL; } virtual bool isViewerOperation() {return false;} + virtual bool isPreviewOperation() {return false;} protected: NodeOperation(); diff --git a/source/blender/compositor/intern/COM_OutputSocket.cpp b/source/blender/compositor/intern/COM_OutputSocket.cpp index 00d3518cd15..708b2d65d46 100644 --- a/source/blender/compositor/intern/COM_OutputSocket.cpp +++ b/source/blender/compositor/intern/COM_OutputSocket.cpp @@ -47,8 +47,13 @@ void OutputSocket::determineResolution(unsigned int resolution[], unsigned int p NodeBase *node = this->getNode(); if (node->isOperation()) { NodeOperation *operation = (NodeOperation*)node; - operation->determineResolution(resolution, preferredResolution); - operation->setResolution(resolution); + if (operation->isResolutionSet()) { + resolution[0] = operation->getWidth(); + resolution[1] = operation->getHeight(); + } else { + operation->determineResolution(resolution, preferredResolution); + operation->setResolution(resolution); + } } } diff --git a/source/blender/compositor/nodes/COM_GroupNode.cpp b/source/blender/compositor/nodes/COM_GroupNode.cpp index ec06a3acd7e..8a8c1db86b4 100644 --- a/source/blender/compositor/nodes/COM_GroupNode.cpp +++ b/source/blender/compositor/nodes/COM_GroupNode.cpp @@ -34,6 +34,7 @@ void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext * void GroupNode::ungroup(ExecutionSystem &system) { + bNode * bnode = this->getbNode(); vector &inputsockets = this->getInputSockets(); vector &outputsockets = this->getOutputSockets(); unsigned int index; @@ -45,7 +46,7 @@ void GroupNode::ungroup(ExecutionSystem &system) InputSocket * inputSocket = inputsockets[index]; bNodeSocket *editorInput = inputSocket->getbNodeSocket(); if (editorInput->groupsock) { - SocketProxyNode * proxy = new SocketProxyNode(this->getbNode(), editorInput, editorInput->groupsock); + SocketProxyNode * proxy = new SocketProxyNode(bnode, editorInput, editorInput->groupsock); inputSocket->relinkConnections(proxy->getInputSocket(0), index, &system); ExecutionSystemHelper::addNode(system.getNodes(), proxy); } @@ -55,12 +56,12 @@ void GroupNode::ungroup(ExecutionSystem &system) OutputSocket * outputSocket = outputsockets[index]; bNodeSocket *editorOutput = outputSocket->getbNodeSocket(); if (editorOutput->groupsock) { - SocketProxyNode * proxy = new SocketProxyNode(this->getbNode(), editorOutput->groupsock, editorOutput); + SocketProxyNode * proxy = new SocketProxyNode(bnode, editorOutput->groupsock, editorOutput); outputSocket->relinkConnections(proxy->getOutputSocket(0)); ExecutionSystemHelper::addNode(system.getNodes(), proxy); } } - bNodeTree *subtree = (bNodeTree*)this->getbNode()->id; - ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree); + bNodeTree *subtree = (bNodeTree*)bnode->id; + ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree, bnode); } diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp index bf434c164c0..8bf9fd2bf06 100644 --- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp @@ -40,7 +40,7 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont SplitViewerOperation *splitViewerOperation = new SplitViewerOperation(); splitViewerOperation->setImage(image); splitViewerOperation->setImageUser(imageUser); - splitViewerOperation->setActive(this->getbNode()->flag & NODE_DO_OUTPUT); + splitViewerOperation->setActive((this->getbNode()->flag & NODE_DO_OUTPUT) && this->isInActiveGroup()); splitViewerOperation->setSplitPercentage(this->getbNode()->custom1); splitViewerOperation->setXSplit(!this->getbNode()->custom2); image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0, graph); diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp index f5dab52d021..67c0df4d6a3 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp @@ -44,7 +44,7 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * viewerOperation->setbNodeTree(context->getbNodeTree()); viewerOperation->setImage(image); viewerOperation->setImageUser(imageUser); - viewerOperation->setActive(editorNode->flag & NODE_DO_OUTPUT); + viewerOperation->setActive((editorNode->flag & NODE_DO_OUTPUT) && this->isInActiveGroup()); viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1); viewerOperation->setCenterX(editorNode->custom3); viewerOperation->setCenterY(editorNode->custom4); diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp index 71a87dce2a7..b4811c89dc5 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp @@ -86,6 +86,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * float overallmultiplyerr = 0; float overallmultiplyerg = 0; float overallmultiplyerb = 0; + float overallmultiplyera = 0; MemoryBuffer *inputBuffer = (MemoryBuffer*)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -115,16 +116,18 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * tempColor[0] += bokeh[0] * buffer[bufferindex]; tempColor[1] += bokeh[1] * buffer[bufferindex+1]; tempColor[2] += bokeh[2]* buffer[bufferindex+2]; + tempColor[3] += bokeh[3]* buffer[bufferindex+3]; overallmultiplyerr += bokeh[0]; overallmultiplyerg += bokeh[1]; overallmultiplyerb += bokeh[2]; + overallmultiplyera += bokeh[3]; bufferindex +=offsetadd; } } color[0] = tempColor[0] * (1.0f / overallmultiplyerr); color[1] = tempColor[1] * (1.0f / overallmultiplyerg); color[2] = tempColor[2] * (1.0f / overallmultiplyerb); - color[3] = 1.0f; + color[3] = tempColor[3] * (1.0f / overallmultiplyera); } else { inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers); diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp index a0297b12961..189ba98aa57 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp @@ -105,7 +105,7 @@ void BokehImageOperation::executePixel(float *color, float x, float y, PixelSamp color[1] = insideBokehMed; color[2] = insideBokehMax; } - color[3] = 1.0f; + color[3] = (insideBokehMax+insideBokehMed+insideBokehMin)/3.0f; } void BokehImageOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index d75cb39325f..c6e8faaa638 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -102,7 +102,7 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem int y1 = rect->ymin; int x2 = rect->xmax; int y2 = rect->ymax; - int offset = (y1*this->getWidth() + x1 ) * 4; + int offset = (y1*this->getWidth() + x1 ) * COM_NUMBER_OF_CHANNELS; int x; int y; bool breaked = false; @@ -117,12 +117,12 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem buffer[offset+1] = color[1]; buffer[offset+2] = color[2]; buffer[offset+3] = color[3]; - offset +=4; + offset +=COM_NUMBER_OF_CHANNELS; if (tree->test_break && tree->test_break(tree->tbh)) { breaked = true; } } - offset += (this->getWidth()-(x2-x1))*4; + offset += (this->getWidth()-(x2-x1))*COM_NUMBER_OF_CHANNELS; } } @@ -130,6 +130,19 @@ void CompositorOperation::determineResolution(unsigned int resolution[], unsigne { int width = this->scene->r.xsch*this->scene->r.size/100; int height = this->scene->r.ysch*this->scene->r.size/100; + + // check actual render resolution with cropping it may differ with cropped border.rendering + // FIX for: [31777] Border Crop gives black (easy) + Render *re= RE_GetRender(this->scene->id.name); + if (re) { + RenderResult *rr= RE_AcquireResultRead(re); + if (rr) { + width = rr->rectx; + height = rr->recty; + } + RE_ReleaseResult(re); + } + preferredResolution[0] = width; preferredResolution[1] = height; diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h index 3d1cd38a5ea..2b81b914746 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.h +++ b/source/blender/compositor/operations/COM_PreviewOperation.h @@ -50,5 +50,7 @@ public: void setbNode(bNode *node) { this->node = node;} void setbNodeTree(const bNodeTree *tree) { this->tree = tree;} bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + bool isPreviewOperation() {return true;} + }; #endif diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index d7f95c10cfb..14b6db9037b 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -75,3 +75,11 @@ bool ReadBufferOperation::determineDependingAreaOfInterest(rcti * input, ReadBuf } return false; } + +void ReadBufferOperation::readResolutionFromWriteBuffer() { + if (this->memoryProxy != NULL) { + WriteBufferOperation * operation = memoryProxy->getWriteBufferOperation(); + this->setWidth(operation->getWidth()); + this->setHeight(operation->getHeight()); + } +} diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h index d58d131264b..449b4a82618 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.h +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h @@ -45,7 +45,7 @@ public: unsigned int getOffset() {return this->offset;} bool determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output); MemoryBuffer *getInputMemoryBuffer(MemoryBuffer** memoryBuffers) {return memoryBuffers[offset];} - + void readResolutionFromWriteBuffer(); }; #endif diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp index af2633f0e53..a391a26b89c 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.cpp +++ b/source/blender/compositor/operations/COM_RotateOperation.cpp @@ -32,6 +32,7 @@ RotateOperation::RotateOperation() : NodeOperation() this->imageSocket = NULL; this->degreeSocket = NULL; this->doDegree2RadConversion = false; + this->isDegreeSet = false; } void RotateOperation::initExecution() { @@ -39,17 +40,6 @@ void RotateOperation::initExecution() this->degreeSocket = this->getInputSocketReader(1); this->centerX = this->getWidth()/2.0; this->centerY = this->getHeight()/2.0; - float degree[4]; - this->degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL); - double rad; - if (this->doDegree2RadConversion) { - rad = DEG2RAD((double)degree[0]); - } - else { - rad = degree[0]; - } - this->cosine = cos(rad); - this->sine = sin(rad); } void RotateOperation::deinitExecution() @@ -58,9 +48,28 @@ void RotateOperation::deinitExecution() this->degreeSocket = NULL; } +inline void RotateOperation::ensureDegree() { + if (!isDegreeSet) { + float degree[4]; + this->degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL); + double rad; + if (this->doDegree2RadConversion) { + rad = DEG2RAD((double)degree[0]); + } + else { + rad = degree[0]; + } + this->cosine = cos(rad); + this->sine = sin(rad); + + isDegreeSet = true; + } +} + void RotateOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { + ensureDegree(); const float dy = y - this->centerY; const float dx = x - this->centerX; const float nx = this->centerX+(this->cosine*dx + this->sine*dy); @@ -70,6 +79,7 @@ void RotateOperation::executePixel(float *color,float x, float y, PixelSampler s bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { + ensureDegree(); rcti newInput; const float dxmin = input->xmin - this->centerX; diff --git a/source/blender/compositor/operations/COM_RotateOperation.h b/source/blender/compositor/operations/COM_RotateOperation.h index 9965d1021da..6afed39908b 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.h +++ b/source/blender/compositor/operations/COM_RotateOperation.h @@ -34,6 +34,7 @@ private: float cosine; float sine; bool doDegree2RadConversion; + bool isDegreeSet; public: RotateOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -41,6 +42,8 @@ public: void initExecution(); void deinitExecution(); void setDoDegree2RadConversion(bool abool) {this->doDegree2RadConversion = abool;} + + void ensureDegree(); }; #endif diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cpp b/source/blender/compositor/operations/COM_SetVectorOperation.cpp index 70477de0514..79c0201733e 100644 --- a/source/blender/compositor/operations/COM_SetVectorOperation.cpp +++ b/source/blender/compositor/operations/COM_SetVectorOperation.cpp @@ -38,12 +38,6 @@ void SetVectorOperation::executePixel(float *outputValue, float x, float y, Pixe void SetVectorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { - if (preferredResolution[0] == 0 ||preferredResolution[1]==0) { - resolution[0] = COM_DEFAULT_RESOLUTION_WIDTH; - resolution[1] = COM_DEFAULT_RESOLUTION_HEIGHT; - } - else { - resolution[0] = preferredResolution[0]; - resolution[1] = preferredResolution[1]; - } + resolution[0] = preferredResolution[0]; + resolution[1] = preferredResolution[1]; } diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp index 6ed877523d1..51b16506dd9 100644 --- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp +++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp @@ -41,5 +41,7 @@ void SocketProxyOperation::deinitExecution() void SocketProxyOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - this->inputOperation->read(color, x, y, sampler, inputBuffers); + if (this->inputOperation) { + this->inputOperation->read(color, x, y, sampler, inputBuffers); + } } diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp index 6d2fdfc11d0..b9b06d6d356 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.cpp +++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp @@ -32,6 +32,7 @@ TranslateOperation::TranslateOperation() : NodeOperation() this->inputOperation = NULL; this->inputXOperation = NULL; this->inputYOperation = NULL; + this->isDeltaSet = false; } void TranslateOperation::initExecution() { @@ -39,11 +40,6 @@ void TranslateOperation::initExecution() this->inputXOperation = this->getInputSocketReader(1); this->inputYOperation = this->getInputSocketReader(2); - float tempDelta[4]; - this->inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); - this->deltaX = tempDelta[0]; - this->inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); - this->deltaY = tempDelta[0]; } void TranslateOperation::deinitExecution() @@ -56,11 +52,13 @@ void TranslateOperation::deinitExecution() void TranslateOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { + ensureDelta(); this->inputOperation->read(color, x-this->getDeltaX(), y-this->getDeltaY(), sampler, inputBuffers); } bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { + ensureDelta(); rcti newInput; newInput.xmax = input->xmax - this->getDeltaX(); diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h index eab3391041e..63d6ee0d0b5 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.h +++ b/source/blender/compositor/operations/COM_TranslateOperation.h @@ -32,6 +32,7 @@ private: SocketReader*inputYOperation; float deltaX; float deltaY; + float isDeltaSet; public: TranslateOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -42,6 +43,17 @@ public: float getDeltaX() {return this->deltaX;} float getDeltaY() {return this->deltaY;} + + inline void ensureDelta() { + if (!isDeltaSet) { + float tempDelta[4]; + this->inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); + this->deltaX = tempDelta[0]; + this->inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); + this->deltaY = tempDelta[0]; + this->isDeltaSet = true; + } + } }; #endif diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index 270fedc174b..562b0fc2bb5 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -64,6 +64,7 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me float overallmultiplyerr = 0; float overallmultiplyerg = 0; float overallmultiplyerb = 0; + float overallmultiplyera = 0; int miny = y - maxBlur; int maxy = y + maxBlur; @@ -74,16 +75,18 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me tempColor[0] += readColor[0]; tempColor[1] += readColor[1]; tempColor[2] += readColor[2]; + tempColor[3] += readColor[3]; overallmultiplyerr += 1; overallmultiplyerg += 1; overallmultiplyerb += 1; + overallmultiplyera += 1; for (int ny = miny ; ny < maxy ; ny += QualityStepHelper::getStep()) { for (int nx = minx ; nx < maxx ; nx += QualityStepHelper::getStep()) { if (nx >=0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) { inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); float size = tempSize[0]; - size += this->threshold; +// size += this->threshold; float dx = nx - x; float dy = ny - y; if (nx == x && ny == y) { @@ -94,20 +97,22 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me float v = 256 + dy*256/size; inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); - tempColor[0] += bokeh[0] * readColor[0]; - tempColor[1] += bokeh[1] * readColor[1]; - tempColor[2] += bokeh[2]* readColor[2]; + tempColor[0] += bokeh[1]*readColor[0]; + tempColor[1] += bokeh[2]*readColor[1]; + tempColor[2] += bokeh[2]*readColor[2]; + tempColor[3] += bokeh[3]*readColor[3]; overallmultiplyerr += bokeh[0]; overallmultiplyerg += bokeh[1]; overallmultiplyerb += bokeh[2]; + overallmultiplyera += bokeh[3]; } } } } - color[0] = tempColor[0] * (1.0f / overallmultiplyerr); - color[1] = tempColor[1] * (1.0f / overallmultiplyerg); - color[2] = tempColor[2] * (1.0f / overallmultiplyerb); - color[3] = 1.0f; + color[0] = tempColor[0] / overallmultiplyerr; + color[1] = tempColor[1] / overallmultiplyerg; + color[2] = tempColor[2] / overallmultiplyerb; + color[3] = tempColor[3] / overallmultiplyera; } } diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index 222b879645c..8888d30ba2f 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -175,3 +175,9 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr } delete clKernelsToCleanUp; } + +void WriteBufferOperation::readResolutionFromInputSocket() { + NodeOperation* inputOperation = this->getInputOperation(0); + this->setWidth(inputOperation->getWidth()); + this->setHeight(inputOperation->getHeight()); +} diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h index 6f2c49c49bd..068adc03293 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.h +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h @@ -47,6 +47,7 @@ public: void deinitExecution(); void setbNodeTree(const bNodeTree *tree) {this->tree = tree;} void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer** memoryBuffers, MemoryBuffer* outputBuffer); + void readResolutionFromInputSocket(); }; #endif -- cgit v1.2.3