[Bf-blender-cvs] [02fad7d] master: Fix T42844: Compositor scale offset

Sergey Sharybin noreply at git.blender.org
Tue Jan 20 11:06:40 CET 2015


Commit: 02fad7dca4adc5e248440c98293cdf713f25d39d
Author: Sergey Sharybin
Date:   Tue Jan 20 14:46:21 2015 +0500
Branches: master
https://developer.blender.org/rB02fad7dca4adc5e248440c98293cdf713f25d39d

Fix T42844: Compositor scale offset

Different interpolation methods in compositor could lead to 0.5 pixel offset in
final renders. This is because of some inconsistency in integer coordinates
which might mean pixel corner or pixel center.

Should be all fine now.

===================================================================

M	source/blender/compositor/intern/COM_MemoryBuffer.h
M	source/blender/compositor/operations/COM_ImageOperation.cpp
M	source/blender/compositor/operations/COM_MovieClipOperation.cpp
M	source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
M	source/blender/compositor/operations/COM_RenderLayersProg.cpp

===================================================================

diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index 70b4dec..320de3d 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -259,7 +259,7 @@ public:
 		float u = x;
 		float v = y;
 		this->wrap_pixel(u, v, extend_x, extend_y);
-		BLI_bilinear_interpolation_fl(this->m_buffer, result, this->m_width, this->m_height, this->m_num_channels, u, v);
+		BLI_bilinear_interpolation_fl(this->m_buffer, result, this->m_width, this->m_height, this->m_num_channels, u - 0.5f, v - 0.5f);
 	}
 
 	void readEWA(float *result, const float uv[2], const float derivatives[2][2], PixelSampler sampler);
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp
index 2733c48..ff0ffe2 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_ImageOperation.cpp
@@ -119,10 +119,10 @@ static void sampleImageAtLocation(ImBuf *ibuf, float x, float y, PixelSampler sa
 				nearest_interpolation_color(ibuf, NULL, color, x, y);
 				break;
 			case COM_PS_BILINEAR:
-				bilinear_interpolation_color(ibuf, NULL, color, x, y);
+				bilinear_interpolation_color(ibuf, NULL, color, x - 0.5f, y - 0.5f);
 				break;
 			case COM_PS_BICUBIC:
-				bicubic_interpolation_color(ibuf, NULL, color, x, y);
+				bicubic_interpolation_color(ibuf, NULL, color, x - 0.5f, y - 0.5f);
 				break;
 		}
 	}
@@ -133,10 +133,10 @@ static void sampleImageAtLocation(ImBuf *ibuf, float x, float y, PixelSampler sa
 				nearest_interpolation_color(ibuf, byte_color, NULL, x, y);
 				break;
 			case COM_PS_BILINEAR:
-				bilinear_interpolation_color(ibuf, byte_color, NULL, x, y);
+				bilinear_interpolation_color(ibuf, byte_color, NULL, x - 0.5f, y - 0.5f);
 				break;
 			case COM_PS_BICUBIC:
-				bicubic_interpolation_color(ibuf, byte_color, NULL, x, y);
+				bicubic_interpolation_color(ibuf, byte_color, NULL, x - 0.5f, y - 0.5f);
 				break;
 		}
 		rgba_uchar_to_float(color, byte_color);
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
index 9a184ae..2ed498d 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
@@ -103,10 +103,10 @@ void MovieClipBaseOperation::executePixelSampled(float output[4], float x, float
 				nearest_interpolation_color(ibuf, NULL, output, x, y);
 				break;
 			case COM_PS_BILINEAR:
-				bilinear_interpolation_color(ibuf, NULL, output, x, y);
+				bilinear_interpolation_color(ibuf, NULL, output, x - 0.5f, y - 0.5f);
 				break;
 			case COM_PS_BICUBIC:
-				bicubic_interpolation_color(ibuf, NULL, output, x, y);
+				bicubic_interpolation_color(ibuf, NULL, output, x - 0.5f, y - 0.5f);
 				break;
 		}
 	}
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
index 23fba5a..35ab20f 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
@@ -54,10 +54,10 @@ void MultilayerColorOperation::executePixelSampled(float output[4], float x, flo
 					nearest_interpolation_color(this->m_buffer, NULL, output, x, y);
 					break;
 				case COM_PS_BILINEAR:
-					bilinear_interpolation_color(this->m_buffer, NULL, output, x, y);
+					bilinear_interpolation_color(this->m_buffer, NULL, output, x - 0.5f, y - 0.5f);
 					break;
 				case COM_PS_BICUBIC:
-					bicubic_interpolation_color(this->m_buffer, NULL, output, x, y);
+					bicubic_interpolation_color(this->m_buffer, NULL, output, x - 0.5f, y - 0.5f);
 					break;
 			}
 		}
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
index f199045..8e778e4 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@ -104,11 +104,11 @@ void RenderLayersBaseProg::doInterpolation(float output[4], float x, float y, Pi
 		}
 
 		case COM_PS_BILINEAR:
-			BLI_bilinear_interpolation_fl(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
+			BLI_bilinear_interpolation_fl(this->m_inputBuffer, output, width, height, this->m_elementsize, x - 0.5f, y - 0.5f);
 			break;
 
 		case COM_PS_BICUBIC:
-			BLI_bicubic_interpolation_fl(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
+			BLI_bicubic_interpolation_fl(this->m_inputBuffer, output, width, height, this->m_elementsize, x - 0.5f, y - 0.5f);
 			break;
 	}
 }




More information about the Bf-blender-cvs mailing list