* 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
This commit is contained in:
2012-06-12 04:23:21 +00:00
parent 7977078227
commit ac5a735e3f
29 changed files with 214 additions and 76 deletions

View File

@@ -70,6 +70,7 @@ typedef enum CompositorPriority {
// chunk size determination // chunk size determination
#define COM_PREVIEW_SIZE 140.0f #define COM_PREVIEW_SIZE 140.0f
//#define COM_OPENCL_ENABLED //#define COM_OPENCL_ENABLED
//#define COM_DEBUG
// workscheduler threading models // workscheduler threading models
/** /**
@@ -106,7 +107,4 @@ typedef enum OrderOfChunks {
#define COM_NUMBER_OF_CHANNELS 4 #define COM_NUMBER_OF_CHANNELS 4
#define COM_DEFAULT_RESOLUTION_WIDTH 640
#define COM_DEFAULT_RESOLUTION_HEIGHT 480
#endif #endif

View File

@@ -29,6 +29,7 @@ CompositorContext::CompositorContext()
this->scene = NULL; this->scene = NULL;
this->quality = COM_QUALITY_HIGH; this->quality = COM_QUALITY_HIGH;
this->hasActiveOpenCLDevices = false; this->hasActiveOpenCLDevices = false;
this->activegNode = NULL;
} }
const int CompositorContext::getFramenumber() const const int CompositorContext::getFramenumber() const

View File

@@ -63,6 +63,11 @@ private:
* @see ExecutionSystem * @see ExecutionSystem
*/ */
bNodeTree *bnodetree; bNodeTree *bnodetree;
/**
* @brief activegNode the group node that is currently being edited.
*/
bNode *activegNode;
/** /**
* @brief does this system have active opencl devices? * @brief does this system have active opencl devices?
@@ -100,6 +105,16 @@ public:
*/ */
const bNodeTree * getbNodeTree() const {return this->bnodetree;} 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 * @brief get the scene of the context
*/ */

View File

@@ -184,11 +184,8 @@ void ExecutionGroup::deinitExecution()
void ExecutionGroup::determineResolution(unsigned int resolution[]) void ExecutionGroup::determineResolution(unsigned int resolution[])
{ {
NodeOperation *operation = this->getOutputNodeOperation(); NodeOperation *operation = this->getOutputNodeOperation();
unsigned int preferredResolution[2]; resolution[0] = operation->getWidth();
preferredResolution[0] = 0; resolution[1] = operation->getHeight();
preferredResolution[1] = 0;
operation->determineResolution(resolution, preferredResolution);
operation->setResolution(resolution);
this->setResolution(resolution); this->setResolution(resolution);
} }

View File

@@ -41,7 +41,14 @@
ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering) 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 */ /* initialize the CompositorContext */
if (rendering) { if (rendering) {
@@ -55,25 +62,25 @@ ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering)
Node *mainOutputNode=NULL; Node *mainOutputNode=NULL;
mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree); mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL);
if (mainOutputNode) { if (mainOutputNode) {
context.setScene((Scene*)mainOutputNode->getbNode()->id); context.setScene((Scene*)mainOutputNode->getbNode()->id);
this->convertToOperations(); this->convertToOperations();
this->groupOperations(); /* group operations in ExecutionGroups */ this->groupOperations(); /* group operations in ExecutionGroups */
vector<ExecutionGroup*> executionGroups;
this->findOutputExecutionGroup(&executionGroups);
unsigned int index; unsigned int index;
unsigned int resolution[2]; unsigned int resolution[2];
for (index = 0 ; index < executionGroups.size(); index ++) { for (index = 0 ; index < this->groups.size(); index ++) {
resolution[0]=0; resolution[0]=0;
resolution[1]=0; resolution[1]=0;
ExecutionGroup *executionGroup = executionGroups[index]; ExecutionGroup *executionGroup = groups[index];
executionGroup->determineResolution(resolution); executionGroup->determineResolution(resolution);
} }
} }
if (G.f & G_DEBUG) ExecutionSystemHelper::debugDump(this); #ifdef COM_DEBUG
ExecutionSystemHelper::debugDump(this);
#endif
} }
ExecutionSystem::~ExecutionSystem() ExecutionSystem::~ExecutionSystem()
@@ -180,11 +187,13 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation)
writeoperation->setbNodeTree(this->getContext().getbNodeTree()); writeoperation->setbNodeTree(this->getContext().getbNodeTree());
this->addOperation(writeoperation); this->addOperation(writeoperation);
ExecutionSystemHelper::addLink(this->getConnections(), fromsocket, writeoperation->getInputSocket(0)); ExecutionSystemHelper::addLink(this->getConnections(), fromsocket, writeoperation->getInputSocket(0));
writeoperation->readResolutionFromInputSocket();
} }
ReadBufferOperation *readoperation = new ReadBufferOperation(); ReadBufferOperation *readoperation = new ReadBufferOperation();
readoperation->setMemoryProxy(writeoperation->getMemoryProxy()); readoperation->setMemoryProxy(writeoperation->getMemoryProxy());
connection->setFromSocket(readoperation->getOutputSocket()); connection->setFromSocket(readoperation->getOutputSocket());
readoperation->getOutputSocket()->addConnection(connection); readoperation->getOutputSocket()->addConnection(connection);
readoperation->readResolutionFromWriteBuffer();
this->addOperation(readoperation); this->addOperation(readoperation);
} }
} }
@@ -207,9 +216,11 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation)
readoperation->setMemoryProxy(writeOperation->getMemoryProxy()); readoperation->setMemoryProxy(writeOperation->getMemoryProxy());
connection->setFromSocket(readoperation->getOutputSocket()); connection->setFromSocket(readoperation->getOutputSocket());
readoperation->getOutputSocket()->addConnection(connection); readoperation->getOutputSocket()->addConnection(connection);
readoperation->readResolutionFromWriteBuffer();
this->addOperation(readoperation); this->addOperation(readoperation);
} }
ExecutionSystemHelper::addLink(this->getConnections(), outputsocket, writeOperation->getInputSocket(0)); 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) // determine all resolutions of the operations (Width/Height)
for (index = 0 ; index < this->operations.size(); index ++) { for (index = 0 ; index < this->operations.size(); index ++) {
NodeOperation *operation = this->operations[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 resolution[2] = {0,0};
unsigned int preferredResolution[2] = {0,0}; unsigned int preferredResolution[2] = {0,0};
operation->determineResolution(resolution, preferredResolution); operation->determineResolution(resolution, preferredResolution);

View File

@@ -35,16 +35,20 @@
#include "COM_GroupNode.h" #include "COM_GroupNode.h"
#include "COM_WriteBufferOperation.h" #include "COM_WriteBufferOperation.h"
#include "COM_ReadBufferOperation.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<Node*>& nodes = system.getNodes(); vector<Node*>& nodes = system.getNodes();
vector<SocketConnection*>& links = system.getConnections(); vector<SocketConnection*>& links = system.getConnections();
Node *mainnode = NULL; Node *mainnode = NULL;
const bNode * activeGroupNode = system.getContext().getActivegNode();
bool isActiveGroup = activeGroupNode == groupnode;
/* add all nodes of the tree to the node list */ /* add all nodes of the tree to the node list */
bNode *node = (bNode*)tree->nodes.first; bNode *node = (bNode*)tree->nodes.first;
while (node != NULL) { while (node != NULL) {
Node *execnode = addNode(nodes, node); Node *execnode = addNode(nodes, node, isActiveGroup);
if (node->type == CMP_NODE_COMPOSITE) { if (node->type == CMP_NODE_COMPOSITE) {
mainnode = execnode; mainnode = execnode;
} }
@@ -77,11 +81,12 @@ void ExecutionSystemHelper::addNode(vector<Node*>& nodes, Node *node)
nodes.push_back(node); nodes.push_back(node);
} }
Node *ExecutionSystemHelper::addNode(vector<Node*>& nodes, bNode *bNode) Node *ExecutionSystemHelper::addNode(vector<Node*>& nodes, bNode *bNode, bool inActiveGroup)
{ {
Converter converter; Converter converter;
Node * node; Node * node;
node = converter.convert(bNode); node = converter.convert(bNode);
node->setIsInActiveGroup(inActiveGroup);
if (node != NULL) { if (node != NULL) {
addNode(nodes, node); addNode(nodes, node);
return node; return node;
@@ -232,7 +237,12 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system)
printf("|"); printf("|");
} }
if (operation->isViewerOperation()) { 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())) { else if (operation->isOutputOperation(system->getContext().isRendering())) {
printf("Output"); printf("Output");
@@ -249,6 +259,7 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system)
else { else {
printf("O_%p", operation); printf("O_%p", operation);
} }
printf(" (%d,%d)", operation->getWidth(), operation->getHeight());
tot2 = operation->getNumberOfOutputSockets(); tot2 = operation->getNumberOfOutputSockets();
if (tot2 != 0) { if (tot2 != 0) {
printf("|"); printf("|");

View File

@@ -48,7 +48,7 @@ public:
* @param tree bNodeTree to add * @param tree bNodeTree to add
* @return Node representing the "Compositor node" of the maintree. or NULL when a subtree is added * @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. * @brief add an editor node to the system.
@@ -58,7 +58,7 @@ public:
* @param bNode node to add * @param bNode node to add
* @return Node that represents the bNode or null when not able to convert. * @return Node that represents the bNode or null when not able to convert.
*/ */
static Node *addNode(vector<Node*>& nodes, bNode *bNode); static Node *addNode(vector<Node*>& nodes, bNode *bNode, bool isInActiveGroup);
/** /**
* @brief Add a Node to a list * @brief Add a Node to a list

View File

@@ -85,16 +85,18 @@ void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket
void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket) void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket)
{ {
PreviewOperation *operation = new PreviewOperation(); if (this->isInActiveGroup()) {
system->addOperation(operation); PreviewOperation *operation = new PreviewOperation();
operation->setbNode(this->getbNode()); system->addOperation(operation);
operation->setbNodeTree(system->getContext().getbNodeTree()); operation->setbNode(this->getbNode());
this->addLink(system, outputSocket, operation->getInputSocket(0)); operation->setbNodeTree(system->getContext().getbNodeTree());
this->addLink(system, outputSocket, operation->getInputSocket(0));
}
} }
void Node::addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket) void Node::addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket)
{ {
if (inputSocket->isConnected()) { if (inputSocket->isConnected() && this->isInActiveGroup()) {
OutputSocket *outputsocket = inputSocket->getConnection()->getFromSocket(); OutputSocket *outputsocket = inputSocket->getConnection()->getFromSocket();
this->addPreviewOperation(system, outputsocket); this->addPreviewOperation(system, outputsocket);
} }

View File

@@ -52,6 +52,11 @@ private:
*/ */
bNode *editorNode; bNode *editorNode;
/**
* @brief Is this node part of the active group
*/
bool inActiveGroup;
public: public:
Node(bNode *editorNode, bool create_sockets=true); Node(bNode *editorNode, bool create_sockets=true);
@@ -60,6 +65,20 @@ public:
*/ */
bNode *getbNode(); 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 * @brief convert node to operation
* *

View File

@@ -160,11 +160,22 @@ public:
virtual void deinitExecution(); virtual void deinitExecution();
void deinitMutex(); void deinitMutex();
bool isResolutionSet() {
return this->width != 0 && height != 0;
}
/** /**
* @brief set the resolution * @brief set the resolution
* @param resolution the resolution to set * @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<InputSocket*> *sockets); void getConnectedInputSockets(vector<InputSocket*> *sockets);
/** /**
@@ -221,6 +232,7 @@ public:
bool isOpenCL() { return this->openCL; } bool isOpenCL() { return this->openCL; }
virtual bool isViewerOperation() {return false;} virtual bool isViewerOperation() {return false;}
virtual bool isPreviewOperation() {return false;}
protected: protected:
NodeOperation(); NodeOperation();

View File

@@ -47,8 +47,13 @@ void OutputSocket::determineResolution(unsigned int resolution[], unsigned int p
NodeBase *node = this->getNode(); NodeBase *node = this->getNode();
if (node->isOperation()) { if (node->isOperation()) {
NodeOperation *operation = (NodeOperation*)node; NodeOperation *operation = (NodeOperation*)node;
operation->determineResolution(resolution, preferredResolution); if (operation->isResolutionSet()) {
operation->setResolution(resolution); resolution[0] = operation->getWidth();
resolution[1] = operation->getHeight();
} else {
operation->determineResolution(resolution, preferredResolution);
operation->setResolution(resolution);
}
} }
} }

View File

@@ -34,6 +34,7 @@ void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
void GroupNode::ungroup(ExecutionSystem &system) void GroupNode::ungroup(ExecutionSystem &system)
{ {
bNode * bnode = this->getbNode();
vector<InputSocket*> &inputsockets = this->getInputSockets(); vector<InputSocket*> &inputsockets = this->getInputSockets();
vector<OutputSocket*> &outputsockets = this->getOutputSockets(); vector<OutputSocket*> &outputsockets = this->getOutputSockets();
unsigned int index; unsigned int index;
@@ -45,7 +46,7 @@ void GroupNode::ungroup(ExecutionSystem &system)
InputSocket * inputSocket = inputsockets[index]; InputSocket * inputSocket = inputsockets[index];
bNodeSocket *editorInput = inputSocket->getbNodeSocket(); bNodeSocket *editorInput = inputSocket->getbNodeSocket();
if (editorInput->groupsock) { 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); inputSocket->relinkConnections(proxy->getInputSocket(0), index, &system);
ExecutionSystemHelper::addNode(system.getNodes(), proxy); ExecutionSystemHelper::addNode(system.getNodes(), proxy);
} }
@@ -55,12 +56,12 @@ void GroupNode::ungroup(ExecutionSystem &system)
OutputSocket * outputSocket = outputsockets[index]; OutputSocket * outputSocket = outputsockets[index];
bNodeSocket *editorOutput = outputSocket->getbNodeSocket(); bNodeSocket *editorOutput = outputSocket->getbNodeSocket();
if (editorOutput->groupsock) { 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)); outputSocket->relinkConnections(proxy->getOutputSocket(0));
ExecutionSystemHelper::addNode(system.getNodes(), proxy); ExecutionSystemHelper::addNode(system.getNodes(), proxy);
} }
} }
bNodeTree *subtree = (bNodeTree*)this->getbNode()->id; bNodeTree *subtree = (bNodeTree*)bnode->id;
ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree); ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree, bnode);
} }

View File

@@ -40,7 +40,7 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont
SplitViewerOperation *splitViewerOperation = new SplitViewerOperation(); SplitViewerOperation *splitViewerOperation = new SplitViewerOperation();
splitViewerOperation->setImage(image); splitViewerOperation->setImage(image);
splitViewerOperation->setImageUser(imageUser); 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->setSplitPercentage(this->getbNode()->custom1);
splitViewerOperation->setXSplit(!this->getbNode()->custom2); splitViewerOperation->setXSplit(!this->getbNode()->custom2);
image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0, graph); image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0, graph);

View File

@@ -44,7 +44,7 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
viewerOperation->setbNodeTree(context->getbNodeTree()); viewerOperation->setbNodeTree(context->getbNodeTree());
viewerOperation->setImage(image); viewerOperation->setImage(image);
viewerOperation->setImageUser(imageUser); 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->setChunkOrder((OrderOfChunks)editorNode->custom1);
viewerOperation->setCenterX(editorNode->custom3); viewerOperation->setCenterX(editorNode->custom3);
viewerOperation->setCenterY(editorNode->custom4); viewerOperation->setCenterY(editorNode->custom4);

View File

@@ -86,6 +86,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
float overallmultiplyerr = 0; float overallmultiplyerr = 0;
float overallmultiplyerg = 0; float overallmultiplyerg = 0;
float overallmultiplyerb = 0; float overallmultiplyerb = 0;
float overallmultiplyera = 0;
MemoryBuffer *inputBuffer = (MemoryBuffer*)data; MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
float *buffer = inputBuffer->getBuffer(); float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth(); 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[0] += bokeh[0] * buffer[bufferindex];
tempColor[1] += bokeh[1] * buffer[bufferindex+1]; tempColor[1] += bokeh[1] * buffer[bufferindex+1];
tempColor[2] += bokeh[2]* buffer[bufferindex+2]; tempColor[2] += bokeh[2]* buffer[bufferindex+2];
tempColor[3] += bokeh[3]* buffer[bufferindex+3];
overallmultiplyerr += bokeh[0]; overallmultiplyerr += bokeh[0];
overallmultiplyerg += bokeh[1]; overallmultiplyerg += bokeh[1];
overallmultiplyerb += bokeh[2]; overallmultiplyerb += bokeh[2];
overallmultiplyera += bokeh[3];
bufferindex +=offsetadd; bufferindex +=offsetadd;
} }
} }
color[0] = tempColor[0] * (1.0f / overallmultiplyerr); color[0] = tempColor[0] * (1.0f / overallmultiplyerr);
color[1] = tempColor[1] * (1.0f / overallmultiplyerg); color[1] = tempColor[1] * (1.0f / overallmultiplyerg);
color[2] = tempColor[2] * (1.0f / overallmultiplyerb); color[2] = tempColor[2] * (1.0f / overallmultiplyerb);
color[3] = 1.0f; color[3] = tempColor[3] * (1.0f / overallmultiplyera);
} }
else { else {
inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers); inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers);

View File

@@ -105,7 +105,7 @@ void BokehImageOperation::executePixel(float *color, float x, float y, PixelSamp
color[1] = insideBokehMed; color[1] = insideBokehMed;
color[2] = insideBokehMax; color[2] = insideBokehMax;
} }
color[3] = 1.0f; color[3] = (insideBokehMax+insideBokehMed+insideBokehMin)/3.0f;
} }
void BokehImageOperation::deinitExecution() void BokehImageOperation::deinitExecution()

View File

@@ -102,7 +102,7 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem
int y1 = rect->ymin; int y1 = rect->ymin;
int x2 = rect->xmax; int x2 = rect->xmax;
int y2 = rect->ymax; int y2 = rect->ymax;
int offset = (y1*this->getWidth() + x1 ) * 4; int offset = (y1*this->getWidth() + x1 ) * COM_NUMBER_OF_CHANNELS;
int x; int x;
int y; int y;
bool breaked = false; bool breaked = false;
@@ -117,12 +117,12 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem
buffer[offset+1] = color[1]; buffer[offset+1] = color[1];
buffer[offset+2] = color[2]; buffer[offset+2] = color[2];
buffer[offset+3] = color[3]; buffer[offset+3] = color[3];
offset +=4; offset +=COM_NUMBER_OF_CHANNELS;
if (tree->test_break && tree->test_break(tree->tbh)) { if (tree->test_break && tree->test_break(tree->tbh)) {
breaked = true; 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 width = this->scene->r.xsch*this->scene->r.size/100;
int height = this->scene->r.ysch*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[0] = width;
preferredResolution[1] = height; preferredResolution[1] = height;

View File

@@ -50,5 +50,7 @@ public:
void setbNode(bNode *node) { this->node = node;} void setbNode(bNode *node) { this->node = node;}
void setbNodeTree(const bNodeTree *tree) { this->tree = tree;} void setbNodeTree(const bNodeTree *tree) { this->tree = tree;}
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
bool isPreviewOperation() {return true;}
}; };
#endif #endif

View File

@@ -75,3 +75,11 @@ bool ReadBufferOperation::determineDependingAreaOfInterest(rcti * input, ReadBuf
} }
return false; return false;
} }
void ReadBufferOperation::readResolutionFromWriteBuffer() {
if (this->memoryProxy != NULL) {
WriteBufferOperation * operation = memoryProxy->getWriteBufferOperation();
this->setWidth(operation->getWidth());
this->setHeight(operation->getHeight());
}
}

View File

@@ -45,7 +45,7 @@ public:
unsigned int getOffset() {return this->offset;} unsigned int getOffset() {return this->offset;}
bool determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output); bool determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output);
MemoryBuffer *getInputMemoryBuffer(MemoryBuffer** memoryBuffers) {return memoryBuffers[offset];} MemoryBuffer *getInputMemoryBuffer(MemoryBuffer** memoryBuffers) {return memoryBuffers[offset];}
void readResolutionFromWriteBuffer();
}; };
#endif #endif

View File

@@ -32,6 +32,7 @@ RotateOperation::RotateOperation() : NodeOperation()
this->imageSocket = NULL; this->imageSocket = NULL;
this->degreeSocket = NULL; this->degreeSocket = NULL;
this->doDegree2RadConversion = false; this->doDegree2RadConversion = false;
this->isDegreeSet = false;
} }
void RotateOperation::initExecution() void RotateOperation::initExecution()
{ {
@@ -39,17 +40,6 @@ void RotateOperation::initExecution()
this->degreeSocket = this->getInputSocketReader(1); this->degreeSocket = this->getInputSocketReader(1);
this->centerX = this->getWidth()/2.0; this->centerX = this->getWidth()/2.0;
this->centerY = this->getHeight()/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() void RotateOperation::deinitExecution()
@@ -58,9 +48,28 @@ void RotateOperation::deinitExecution()
this->degreeSocket = NULL; 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[]) void RotateOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{ {
ensureDegree();
const float dy = y - this->centerY; const float dy = y - this->centerY;
const float dx = x - this->centerX; const float dx = x - this->centerX;
const float nx = this->centerX+(this->cosine*dx + this->sine*dy); 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) bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{ {
ensureDegree();
rcti newInput; rcti newInput;
const float dxmin = input->xmin - this->centerX; const float dxmin = input->xmin - this->centerX;

View File

@@ -34,6 +34,7 @@ private:
float cosine; float cosine;
float sine; float sine;
bool doDegree2RadConversion; bool doDegree2RadConversion;
bool isDegreeSet;
public: public:
RotateOperation(); RotateOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
@@ -41,6 +42,8 @@ public:
void initExecution(); void initExecution();
void deinitExecution(); void deinitExecution();
void setDoDegree2RadConversion(bool abool) {this->doDegree2RadConversion = abool;} void setDoDegree2RadConversion(bool abool) {this->doDegree2RadConversion = abool;}
void ensureDegree();
}; };
#endif #endif

View File

@@ -38,12 +38,6 @@ void SetVectorOperation::executePixel(float *outputValue, float x, float y, Pixe
void SetVectorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) void SetVectorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{ {
if (preferredResolution[0] == 0 ||preferredResolution[1]==0) { resolution[0] = preferredResolution[0];
resolution[0] = COM_DEFAULT_RESOLUTION_WIDTH; resolution[1] = preferredResolution[1];
resolution[1] = COM_DEFAULT_RESOLUTION_HEIGHT;
}
else {
resolution[0] = preferredResolution[0];
resolution[1] = preferredResolution[1];
}
} }

View File

@@ -41,5 +41,7 @@ void SocketProxyOperation::deinitExecution()
void SocketProxyOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) 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);
}
} }

View File

@@ -32,6 +32,7 @@ TranslateOperation::TranslateOperation() : NodeOperation()
this->inputOperation = NULL; this->inputOperation = NULL;
this->inputXOperation = NULL; this->inputXOperation = NULL;
this->inputYOperation = NULL; this->inputYOperation = NULL;
this->isDeltaSet = false;
} }
void TranslateOperation::initExecution() void TranslateOperation::initExecution()
{ {
@@ -39,11 +40,6 @@ void TranslateOperation::initExecution()
this->inputXOperation = this->getInputSocketReader(1); this->inputXOperation = this->getInputSocketReader(1);
this->inputYOperation = this->getInputSocketReader(2); 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() void TranslateOperation::deinitExecution()
@@ -56,11 +52,13 @@ void TranslateOperation::deinitExecution()
void TranslateOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) 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); this->inputOperation->read(color, x-this->getDeltaX(), y-this->getDeltaY(), sampler, inputBuffers);
} }
bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{ {
ensureDelta();
rcti newInput; rcti newInput;
newInput.xmax = input->xmax - this->getDeltaX(); newInput.xmax = input->xmax - this->getDeltaX();

View File

@@ -32,6 +32,7 @@ private:
SocketReader*inputYOperation; SocketReader*inputYOperation;
float deltaX; float deltaX;
float deltaY; float deltaY;
float isDeltaSet;
public: public:
TranslateOperation(); TranslateOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
@@ -42,6 +43,17 @@ public:
float getDeltaX() {return this->deltaX;} float getDeltaX() {return this->deltaX;}
float getDeltaY() {return this->deltaY;} 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 #endif

View File

@@ -64,6 +64,7 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
float overallmultiplyerr = 0; float overallmultiplyerr = 0;
float overallmultiplyerg = 0; float overallmultiplyerg = 0;
float overallmultiplyerb = 0; float overallmultiplyerb = 0;
float overallmultiplyera = 0;
int miny = y - maxBlur; int miny = y - maxBlur;
int maxy = 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[0] += readColor[0];
tempColor[1] += readColor[1]; tempColor[1] += readColor[1];
tempColor[2] += readColor[2]; tempColor[2] += readColor[2];
tempColor[3] += readColor[3];
overallmultiplyerr += 1; overallmultiplyerr += 1;
overallmultiplyerg += 1; overallmultiplyerg += 1;
overallmultiplyerb += 1; overallmultiplyerb += 1;
overallmultiplyera += 1;
for (int ny = miny ; ny < maxy ; ny += QualityStepHelper::getStep()) { for (int ny = miny ; ny < maxy ; ny += QualityStepHelper::getStep()) {
for (int nx = minx ; nx < maxx ; nx += QualityStepHelper::getStep()) { for (int nx = minx ; nx < maxx ; nx += QualityStepHelper::getStep()) {
if (nx >=0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) { if (nx >=0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) {
inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers);
float size = tempSize[0]; float size = tempSize[0];
size += this->threshold; // size += this->threshold;
float dx = nx - x; float dx = nx - x;
float dy = ny - y; float dy = ny - y;
if (nx == x && 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; float v = 256 + dy*256/size;
inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers);
tempColor[0] += bokeh[0] * readColor[0]; tempColor[0] += bokeh[1]*readColor[0];
tempColor[1] += bokeh[1] * readColor[1]; tempColor[1] += bokeh[2]*readColor[1];
tempColor[2] += bokeh[2]* readColor[2]; tempColor[2] += bokeh[2]*readColor[2];
tempColor[3] += bokeh[3]*readColor[3];
overallmultiplyerr += bokeh[0]; overallmultiplyerr += bokeh[0];
overallmultiplyerg += bokeh[1]; overallmultiplyerg += bokeh[1];
overallmultiplyerb += bokeh[2]; overallmultiplyerb += bokeh[2];
overallmultiplyera += bokeh[3];
} }
} }
} }
} }
color[0] = tempColor[0] * (1.0f / overallmultiplyerr); color[0] = tempColor[0] / overallmultiplyerr;
color[1] = tempColor[1] * (1.0f / overallmultiplyerg); color[1] = tempColor[1] / overallmultiplyerg;
color[2] = tempColor[2] * (1.0f / overallmultiplyerb); color[2] = tempColor[2] / overallmultiplyerb;
color[3] = 1.0f; color[3] = tempColor[3] / overallmultiplyera;
} }
} }

View File

@@ -175,3 +175,9 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr
} }
delete clKernelsToCleanUp; delete clKernelsToCleanUp;
} }
void WriteBufferOperation::readResolutionFromInputSocket() {
NodeOperation* inputOperation = this->getInputOperation(0);
this->setWidth(inputOperation->getWidth());
this->setHeight(inputOperation->getHeight());
}

View File

@@ -47,6 +47,7 @@ public:
void deinitExecution(); void deinitExecution();
void setbNodeTree(const bNodeTree *tree) {this->tree = tree;} 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 executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer** memoryBuffers, MemoryBuffer* outputBuffer);
void readResolutionFromInputSocket();
}; };
#endif #endif