[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49922] trunk/blender/source/blender/ compositor/operations: Fix for

Jeroen Bakker j.bakker at atmind.nl
Wed Aug 15 20:14:34 CEST 2012


Revision: 49922
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49922
Author:   jbakker
Date:     2012-08-15 18:14:34 +0000 (Wed, 15 Aug 2012)
Log Message:
-----------
Fix for
 * [#32323] regression: Dispertion artifacts with smaller chunksizes
 * [#32125] "Projector" Dispersion not working with ChunkSize < 256

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h

Modified: trunk/blender/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp	2012-08-15 11:53:49 UTC (rev 49921)
+++ trunk/blender/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp	2012-08-15 18:14:34 UTC (rev 49922)
@@ -80,12 +80,20 @@
 		newInput.xmax = input->xmax + this->m_kr2 + 2;
 	}
 	else {
+		rcti dispInput;
+		BLI_rcti_init(&dispInput, 0,5,0,5);
+		if (this->getInputOperation(1)->determineDependingAreaOfInterest(&dispInput, readOperation, output)) {
+			return true;
+		}
 		newInput.xmin = input->xmin - 7;  /* (0.25f * 20 * 1) + 2 == worse case dispersion */
 		newInput.ymin = input->ymin;
 		newInput.ymax = input->ymax;
 		newInput.xmax = input->xmax + 7;  /* (0.25f * 20 * 1) + 2 == worse case dispersion */
 	}
-	return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+	if (this->getInputOperation(0)->determineDependingAreaOfInterest(&newInput, readOperation, output)) {
+		return true;
+	}
+	return false;
 }
 
 void ProjectorLensDistortionOperation::updateDispersion() 
@@ -94,7 +102,7 @@
 	this->lockMutex();
 	if (!this->m_dispersionAvailable) {
 		float result[4];
-		this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST);
+		this->getInputSocketReader(1)->read(result, 1, 1, COM_PS_NEAREST);
 		this->m_dispersion = result[0];
 		this->m_kr = 0.25f * maxf(minf(this->m_dispersion, 1.0f), 0.0f);
 		this->m_kr2 = this->m_kr * 20;

Modified: trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp	2012-08-15 11:53:49 UTC (rev 49921)
+++ trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp	2012-08-15 18:14:34 UTC (rev 49922)
@@ -145,7 +145,7 @@
 	this->m_inputProgram = NULL;
 }
 
-void ScreenLensDistortionOperation::determineUV(float result[4], float x, float y, float distortion, float dispersion) 
+void ScreenLensDistortionOperation::determineUV(float result[6], float x, float y, float distortion, float dispersion) 
 {
 	if (!this->m_valuesAvailable) {
 		updateVariables(distortion, dispersion);
@@ -153,63 +153,36 @@
 	determineUV(result, x, y);
 }
 
-void ScreenLensDistortionOperation::determineUV(float result[4], float x, float y) const
+void ScreenLensDistortionOperation::determineUV(float result[6], float x, float y) const
 {
 	const float height = this->getHeight();
 	const float width = this->getWidth();
 	
-	float d, t, ln[6] = {0, 0, 0, 0, 0, 0};
+	result[0] = x;
+	result[1] = y;
+	result[2] = x;
+	result[3] = y;
+	result[4] = x;
+	result[5] = y;
+	
+	float d, t;
 	const float v = this->m_sc * ((y + 0.5f) - this->m_cy) / this->m_cy;
 	const float u = this->m_sc * ((x + 0.5f) - this->m_cx) / this->m_cx;
 	const float uv_dot = u * u + v * v;
 
 	if ((t = 1.0f - this->m_kr4 * uv_dot) >= 0.0f) {
 		d = 1.0f / (1.0f + sqrtf(t));
-		ln[0] = (u * d + 0.5f) * width - 0.5f, ln[1] = (v * d + 0.5f) * height - 0.5f;
+		result[0] = (u * d + 0.5f) * width - 0.5f, result[1] = (v * d + 0.5f) * height - 0.5f;
 	}
 	if ((t = 1.0f - this->m_kg4 * uv_dot) >= 0.0f) {
 		d = 1.0f / (1.0f + sqrtf(t));
-		ln[2] = (u * d + 0.5f) * width - 0.5f, ln[3] = (v * d + 0.5f) * height - 0.5f;
+		result[2] = (u * d + 0.5f) * width - 0.5f, result[3] = (v * d + 0.5f) * height - 0.5f;
 	}
 	if ((t = 1.0f - this->m_kb4 * uv_dot) >= 0.0f) {
 		d = 1.0f / (1.0f + sqrtf(t));
-		ln[4] = (u * d + 0.5f) * width - 0.5f, ln[5] = (v * d + 0.5f) * height - 0.5f;
+		result[4] = (u * d + 0.5f) * width - 0.5f, result[5] = (v * d + 0.5f) * height - 0.5f;
 	}
-
-	float jit = this->m_data->jit;
-	float z;
-	{
-		// RG
-		const int dx = ln[2] - ln[0], dy = ln[3] - ln[1];
-		const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.0f;
-		const int ds = (int)(jit ? ((dsf < 4.0f) ? 2.0f : sqrtf(dsf)) : dsf);
-		const float sd = 1.0f / (float)ds;
-
-		z = ds;
-		const float tz = ((float)z + (1.0f)) * sd;
-		t = 1.0f - (this->m_kr4 + tz * this->m_drg) * uv_dot;
-		d = 1.0f / (1.0f + sqrtf(t));
-		const float nx = (u * d + 0.5f) * width - 0.5f;
-		const float ny = (v * d + 0.5f) * height - 0.5f;
-		result[0] = nx;
-		result[1] = ny;
-	}
-	{
-		// GB
-		const int dx = ln[4] - ln[2], dy = ln[5] - ln[3];
-		const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.0f;
-		const int ds = (int)(jit ? ((dsf < 4.0f) ? 2.0f : sqrtf(dsf)) : dsf);
-		const float sd = 1.0f / (float)ds;
-
-		z = ds;
-		const float tz = ((float)z + (1.0f)) * sd;
-		t = 1.0f - (this->m_kg4 + tz * this->m_dgb) * uv_dot;
-		d = 1.0f / (1.0f + sqrtf(t));
-		const float nx = (u * d + 0.5f) * width - 0.5f;
-		const float ny = (v * d + 0.5f) * height - 0.5f;
-		result[2] = nx;
-		result[3] = ny;
-	}
+	
 }
 
 bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
@@ -230,18 +203,16 @@
 		return true;
 	}
 
-#define MARGIN 96
-
 #define UPDATE_INPUT  { \
-		newInput.xmin = MIN3(newInput.xmin, coords[0], coords[2]); \
-		newInput.ymin = MIN3(newInput.ymin, coords[1], coords[3]); \
-		newInput.xmax = MAX3(newInput.xmax, coords[0], coords[2]); \
-		newInput.ymax = MAX3(newInput.ymax, coords[1], coords[3]); \
+		newInput.xmin = MIN4(newInput.xmin, coords[0], coords[2], coords[4]); \
+		newInput.ymin = MIN4(newInput.ymin, coords[1], coords[3], coords[5]); \
+		newInput.xmax = MAX4(newInput.xmax, coords[0], coords[2], coords[4]); \
+		newInput.ymax = MAX4(newInput.ymax, coords[1], coords[3], coords[5]); \
 	} (void)0
 	
 	rcti newInput;
-	float margin;
-	float coords[4];
+	const float margin = 2;
+	float coords[6];
 	if (m_valuesAvailable) {
 		determineUV(coords, input->xmin, input->ymin);
 		newInput.xmin = coords[0];
@@ -255,7 +226,6 @@
 		UPDATE_INPUT;
 		determineUV(coords, input->xmax, input->ymin);
 		UPDATE_INPUT;
-		margin = (fabsf(this->m_distortion) + this->m_dispersion) * MARGIN + 2.0f;
 	} 
 	else {
 		determineUV(coords, input->xmin, input->ymin, 1.0f, 1.0f);
@@ -281,8 +251,6 @@
 		UPDATE_INPUT;
 		determineUV(coords, input->xmax, input->ymin, 1.0f, 1.0f);
 		UPDATE_INPUT;
-		margin = MARGIN;
-		printf("margin b: %f\n", margin);
 	}
 
 #undef UPDATE_INPUT

Modified: trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h	2012-08-15 11:53:49 UTC (rev 49921)
+++ trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h	2012-08-15 18:14:34 UTC (rev 49922)
@@ -79,8 +79,8 @@
 	}
 
 private:
-	void determineUV(float result[4], float x, float y) const;
-	void determineUV(float result[4], float x, float y, float distortion, float dispersion);
+	void determineUV(float result[6], float x, float y) const;
+	void determineUV(float result[6], float x, float y, float distortion, float dispersion);
 	void updateDispersionAndDistortion();
 	void updateVariables(float distortion, float dispersion);
 




More information about the Bf-blender-cvs mailing list