Fix for tiles bug:
[#31981] Bokeh Blur Node - Size input socket does not accept input from Value Input node, Values smaller than 0.1 will produce black output
This commit is contained in:
parent
831ae18622
commit
8a4584d04d
|
@ -37,32 +37,24 @@ BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode)
|
|||
|
||||
void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
|
||||
{
|
||||
// Object *camob = context->getScene()->camera;
|
||||
BokehBlurOperation *operation = new BokehBlurOperation();
|
||||
InputSocket *inputSizeSocket = this->getInputSocket(2);
|
||||
bool connectedSizeSocket = inputSizeSocket->isConnected();
|
||||
|
||||
// if (this->getInputSocket(2)->isConnected()) {
|
||||
// VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
|
||||
// ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation();
|
||||
// converter->setfStop(this->getbNode()->custom3);
|
||||
// converter->setCameraObject(camob);
|
||||
// operation->setMaxBlur((int)this->getbNode()->custom4);
|
||||
// operation->setQuality(context->getQuality());
|
||||
// this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
|
||||
// this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
|
||||
// this->getInputSocket(2)->relinkConnections(converter->getInputSocket(0), 2, graph);
|
||||
// addLink(graph, converter->getOutputSocket(), operation->getInputSocket(2));
|
||||
// graph->addOperation(operation);
|
||||
// graph->addOperation(converter);
|
||||
// this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
|
||||
// }
|
||||
// else {
|
||||
BokehBlurOperation *operation = new BokehBlurOperation();
|
||||
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
|
||||
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
|
||||
this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph);
|
||||
operation->setSize(((bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value);
|
||||
operation->setQuality(context->getQuality());
|
||||
operation->setbNode(this->getbNode());
|
||||
graph->addOperation(operation);
|
||||
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
|
||||
// }
|
||||
const bNodeSocket *sock = this->getInputSocket(2)->getbNodeSocket();
|
||||
const float size = ((const bNodeSocketValueFloat *)sock->default_value)->value;
|
||||
|
||||
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
|
||||
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
|
||||
this->getInputSocket(2)->relinkConnections(operation->getInputSocket(3), 2, graph);
|
||||
this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph);
|
||||
//operation->setSize(((bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value);
|
||||
operation->setQuality(context->getQuality());
|
||||
operation->setbNode(this->getbNode());
|
||||
graph->addOperation(operation);
|
||||
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
|
||||
|
||||
if (!connectedSizeSocket) {
|
||||
operation->setSize(size);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,12 +33,13 @@ BokehBlurOperation::BokehBlurOperation() : NodeOperation()
|
|||
this->addInputSocket(COM_DT_COLOR);
|
||||
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
|
||||
this->addInputSocket(COM_DT_VALUE);
|
||||
this->addInputSocket(COM_DT_VALUE);
|
||||
this->addOutputSocket(COM_DT_COLOR);
|
||||
this->setComplex(true);
|
||||
this->setOpenCL(true);
|
||||
|
||||
this->m_size = 1.0f;
|
||||
|
||||
this->m_sizeavailable = false;
|
||||
this->m_inputProgram = NULL;
|
||||
this->m_inputBokehProgram = NULL;
|
||||
this->m_inputBoundingBoxReader = NULL;
|
||||
|
@ -46,12 +47,20 @@ BokehBlurOperation::BokehBlurOperation() : NodeOperation()
|
|||
|
||||
void *BokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
|
||||
{
|
||||
//void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers);
|
||||
lockMutex();
|
||||
if (!this->m_sizeavailable) {
|
||||
//updateGauss(memoryBuffers);
|
||||
updateSize(memoryBuffers);
|
||||
}
|
||||
void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers);
|
||||
unlockMutex();
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void BokehBlurOperation::initExecution()
|
||||
{
|
||||
initMutex();
|
||||
this->m_inputProgram = getInputSocketReader(0);
|
||||
this->m_inputBokehProgram = getInputSocketReader(1);
|
||||
this->m_inputBoundingBoxReader = getInputSocketReader(2);
|
||||
|
@ -87,7 +96,10 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
|
|||
int bufferstartx = inputBuffer->getRect()->xmin;
|
||||
int bufferstarty = inputBuffer->getRect()->ymin;
|
||||
int pixelSize = this->m_size * this->getWidth() / 100.0f;
|
||||
|
||||
if (pixelSize==0){
|
||||
this->m_inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers);
|
||||
return;
|
||||
}
|
||||
int miny = y - pixelSize;
|
||||
int maxy = y + pixelSize;
|
||||
int minx = x - pixelSize;
|
||||
|
@ -126,6 +138,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
|
|||
|
||||
void BokehBlurOperation::deinitExecution()
|
||||
{
|
||||
deinitMutex();
|
||||
this->m_inputProgram = NULL;
|
||||
this->m_inputBokehProgram = NULL;
|
||||
this->m_inputBoundingBoxReader = NULL;
|
||||
|
@ -136,10 +149,17 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe
|
|||
rcti newInput;
|
||||
rcti bokehInput;
|
||||
|
||||
newInput.xmax = input->xmax + (this->m_size * this->getWidth() / 100.0f);
|
||||
newInput.xmin = input->xmin - (this->m_size * this->getWidth() / 100.0f);
|
||||
newInput.ymax = input->ymax + (this->m_size * this->getWidth() / 100.0f);
|
||||
newInput.ymin = input->ymin - (this->m_size * this->getWidth() / 100.0f);
|
||||
if (this->m_sizeavailable) {
|
||||
newInput.xmax = input->xmax + (this->m_size * this->getWidth() / 100.0f);
|
||||
newInput.xmin = input->xmin - (this->m_size * this->getWidth() / 100.0f);
|
||||
newInput.ymax = input->ymax + (this->m_size * this->getWidth() / 100.0f);
|
||||
newInput.ymin = input->ymin - (this->m_size * this->getWidth() / 100.0f);
|
||||
} else {
|
||||
newInput.xmax = input->xmax + (10.0f * this->getWidth() / 100.0f);
|
||||
newInput.xmin = input->xmin - (10.0f * this->getWidth() / 100.0f);
|
||||
newInput.ymax = input->ymax + (10.0f * this->getWidth() / 100.0f);
|
||||
newInput.ymin = input->ymin - (10.0f * this->getWidth() / 100.0f);
|
||||
}
|
||||
|
||||
NodeOperation *operation = getInputOperation(1);
|
||||
bokehInput.xmax = operation->getWidth();
|
||||
|
@ -157,6 +177,17 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe
|
|||
if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) {
|
||||
return true;
|
||||
}
|
||||
if (!this->m_sizeavailable) {
|
||||
rcti sizeInput;
|
||||
sizeInput.xmin = 0;
|
||||
sizeInput.ymin = 0;
|
||||
sizeInput.xmax = 5;
|
||||
sizeInput.ymax = 5;
|
||||
operation = getInputOperation(3);
|
||||
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -181,3 +212,14 @@ void BokehBlurOperation::executeOpenCL(OpenCLDevice* device,
|
|||
|
||||
device->COM_clEnqueueRange(kernel, outputMemoryBuffer, 9, this);
|
||||
}
|
||||
|
||||
void BokehBlurOperation::updateSize(MemoryBuffer **memoryBuffers)
|
||||
{
|
||||
if (!this->m_sizeavailable) {
|
||||
float result[4];
|
||||
this->getInputSocketReader(3)->read(result, 0, 0, COM_PS_NEAREST, memoryBuffers);
|
||||
this->m_size = result[0];
|
||||
CLAMP(this->m_size, 0.0f, 10.0f);
|
||||
this->m_sizeavailable = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,9 @@ private:
|
|||
SocketReader *m_inputProgram;
|
||||
SocketReader *m_inputBokehProgram;
|
||||
SocketReader *m_inputBoundingBoxReader;
|
||||
void updateSize(MemoryBuffer **memoryBuffers);
|
||||
float m_size;
|
||||
bool m_sizeavailable;
|
||||
float m_bokehMidX;
|
||||
float m_bokehMidY;
|
||||
float m_bokehDimension;
|
||||
|
@ -55,7 +57,7 @@ public:
|
|||
|
||||
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
|
||||
|
||||
void setSize(float size) { this->m_size = size; }
|
||||
void setSize(float size) { this->m_size = size; this->m_sizeavailable = true; }
|
||||
|
||||
void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue