* fixed defocus background blurin...
This commit is contained in:
		@@ -37,24 +37,24 @@ BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode)
 | 
			
		||||
 | 
			
		||||
void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
 | 
			
		||||
{
 | 
			
		||||
	Object *camob = context->getScene()->camera;
 | 
			
		||||
//	Object *camob = context->getScene()->camera;
 | 
			
		||||
 | 
			
		||||
	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 {
 | 
			
		||||
//	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);
 | 
			
		||||
@@ -63,5 +63,5 @@ void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContex
 | 
			
		||||
		operation->setQuality(context->getQuality());
 | 
			
		||||
		graph->addOperation(operation);
 | 
			
		||||
		this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
 | 
			
		||||
	}
 | 
			
		||||
//	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -96,6 +96,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
 | 
			
		||||
	operation->setThreshold(data->bthresh);
 | 
			
		||||
	addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1));
 | 
			
		||||
	addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2));
 | 
			
		||||
	addLink(graph, radiusOperation->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(3));
 | 
			
		||||
	if (data->gamco) {
 | 
			
		||||
		GammaCorrectOperation *correct = new GammaCorrectOperation();
 | 
			
		||||
		GammaUncorrectOperation *inverse = new GammaUncorrectOperation();
 | 
			
		||||
 
 | 
			
		||||
@@ -31,13 +31,15 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation
 | 
			
		||||
{
 | 
			
		||||
	this->addInputSocket(COM_DT_COLOR);
 | 
			
		||||
	this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image.
 | 
			
		||||
	this->addInputSocket(COM_DT_VALUE);
 | 
			
		||||
	this->addInputSocket(COM_DT_VALUE); // radius
 | 
			
		||||
	this->addInputSocket(COM_DT_VALUE); // depth
 | 
			
		||||
	this->addOutputSocket(COM_DT_COLOR);
 | 
			
		||||
	this->setComplex(true);
 | 
			
		||||
 | 
			
		||||
	this->inputProgram = NULL;
 | 
			
		||||
	this->inputBokehProgram = NULL;
 | 
			
		||||
	this->inputSizeProgram = NULL;
 | 
			
		||||
	this->inputDepthProgram = NULL;
 | 
			
		||||
	this->maxBlur = 32.0f;
 | 
			
		||||
	this->threshold = 1.0f;
 | 
			
		||||
}
 | 
			
		||||
@@ -48,6 +50,7 @@ void VariableSizeBokehBlurOperation::initExecution()
 | 
			
		||||
	this->inputProgram = getInputSocketReader(0);
 | 
			
		||||
	this->inputBokehProgram = getInputSocketReader(1);
 | 
			
		||||
	this->inputSizeProgram = getInputSocketReader(2);
 | 
			
		||||
	this->inputDepthProgram = getInputSocketReader(3);
 | 
			
		||||
	QualityStepHelper::initExecution(COM_QH_INCREASE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -56,7 +59,7 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
 | 
			
		||||
	float readColor[4];
 | 
			
		||||
	float bokeh[4];
 | 
			
		||||
	float tempSize[4];
 | 
			
		||||
	float tempSizeCenter[4];
 | 
			
		||||
	float tempDepth[4];
 | 
			
		||||
	float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
 | 
			
		||||
	float color_accum[4]      = {0.0f, 0.0f, 0.0f, 0.0f};
 | 
			
		||||
 | 
			
		||||
@@ -65,17 +68,21 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
 | 
			
		||||
	int minx = x - maxBlur;
 | 
			
		||||
	int maxx = x + maxBlur;
 | 
			
		||||
	{
 | 
			
		||||
		inputSizeProgram->read(tempSizeCenter, x, y, COM_PS_NEAREST, inputBuffers);
 | 
			
		||||
		inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers);
 | 
			
		||||
		inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers);
 | 
			
		||||
		inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers);
 | 
			
		||||
		add_v4_v4(color_accum, readColor);
 | 
			
		||||
		add_v4_fl(multiplier_accum, 1.0f);
 | 
			
		||||
		float sizeCenter = tempSizeCenter[0];
 | 
			
		||||
		float sizeCenter = tempSize[0];
 | 
			
		||||
		float centerDepth = tempDepth[0]+threshold;
 | 
			
		||||
		
 | 
			
		||||
		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()) {
 | 
			
		||||
					inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers);
 | 
			
		||||
					inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers);
 | 
			
		||||
					float size = tempSize[0];
 | 
			
		||||
					if (tempDepth[0] < centerDepth) {
 | 
			
		||||
						if ((sizeCenter > threshold && size > threshold) || size <= threshold) {
 | 
			
		||||
							float dx = nx - x;
 | 
			
		||||
							float dy = ny - y;
 | 
			
		||||
@@ -93,6 +100,7 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		color[0] = color_accum[0] * (1.0f / multiplier_accum[0]);
 | 
			
		||||
		color[1] = color_accum[1] * (1.0f / multiplier_accum[1]);
 | 
			
		||||
@@ -131,6 +139,10 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu
 | 
			
		||||
	if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) {
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	operation = getInputOperation(3);
 | 
			
		||||
	if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	operation = getInputOperation(0);
 | 
			
		||||
	if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
 | 
			
		||||
		return true;
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,7 @@ private:
 | 
			
		||||
	SocketReader *inputProgram;
 | 
			
		||||
	SocketReader *inputBokehProgram;
 | 
			
		||||
	SocketReader *inputSizeProgram;
 | 
			
		||||
	SocketReader *inputDepthProgram;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	VariableSizeBokehBlurOperation();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user