Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc')
-rw-r--r--source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc
index 8bf8e339697..9c19f55e04f 100644
--- a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc
+++ b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc
@@ -43,6 +43,11 @@ BLI_INLINE void warp_coord(float x, float y, float matrix[3][3], float uv[2], fl
uv[0] = vec[0] / vec[2];
uv[1] = vec[1] / vec[2];
+ /* Offset so that pixel center corresponds to a (0.5, 0.5), which helps keeping transformed
+ * image sharp. */
+ uv[0] += 0.5f;
+ uv[1] += 0.5f;
+
deriv[0][0] = (matrix[0][0] - matrix[0][2] * uv[0]) / vec[2];
deriv[1][0] = (matrix[0][1] - matrix[0][2] * uv[1]) / vec[2];
deriv[0][1] = (matrix[1][0] - matrix[1][2] * uv[0]) / vec[2];
@@ -66,9 +71,18 @@ void PlaneDistortWarpImageOperation::calculate_corners(const float corners[4][2]
const NodeOperation *image = get_input_operation(0);
const int width = image->get_width();
const int height = image->get_height();
+
+ MotionSample *sample_data = &samples_[sample];
+
+ /* If the image which is to be warped empty assume unit transform and don't attempt to calculate
+ * actual homography (otherwise homography solver will attempt to deal with singularity). */
+ if (width == 0 || height == 0) {
+ unit_m3(sample_data->perspective_matrix);
+ return;
+ }
+
float frame_corners[4][2] = {
{0.0f, 0.0f}, {(float)width, 0.0f}, {(float)width, (float)height}, {0.0f, (float)height}};
- MotionSample *sample_data = &samples_[sample];
BKE_tracking_homography_between_two_quads(
sample_data->frame_space_corners, frame_corners, sample_data->perspective_matrix);
}