* 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:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
*/
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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<ExecutionGroup*> 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);
|
||||
|
@@ -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<Node*>& nodes = system.getNodes();
|
||||
vector<SocketConnection*>& 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<Node*>& nodes, Node *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;
|
||||
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("|");
|
||||
|
@@ -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<Node*>& nodes, bNode *bNode);
|
||||
static Node *addNode(vector<Node*>& nodes, bNode *bNode, bool isInActiveGroup);
|
||||
|
||||
/**
|
||||
* @brief Add a Node to a list
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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
|
||||
*
|
||||
|
@@ -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<InputSocket*> *sockets);
|
||||
|
||||
/**
|
||||
@@ -221,6 +232,7 @@ public:
|
||||
bool isOpenCL() { return this->openCL; }
|
||||
|
||||
virtual bool isViewerOperation() {return false;}
|
||||
virtual bool isPreviewOperation() {return false;}
|
||||
protected:
|
||||
NodeOperation();
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,7 @@ void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
|
||||
|
||||
void GroupNode::ungroup(ExecutionSystem &system)
|
||||
{
|
||||
bNode * bnode = this->getbNode();
|
||||
vector<InputSocket*> &inputsockets = this->getInputSockets();
|
||||
vector<OutputSocket*> &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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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()
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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];
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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());
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user