Fix #136783: Scaling sometimes causes images to shift
Scaling images in the compositor sometimes causes images to shift, this is because the realization domain was computed using the center of the original image before scaling. To fix this, we make sure the transformation is actually centered. This is rarely apparent and thus no tests need to be updated and this should not be backported for safety. Pull Request: https://projects.blender.org/blender/blender/pulls/147805
This commit is contained in:
@@ -232,12 +232,13 @@ Domain RealizeOnDomainOperation::compute_realized_transformation_domain(
|
||||
const float2 upper_left_corner = float2(0.0f, size.y);
|
||||
const float2 upper_right_corner = float2(size);
|
||||
|
||||
/* Eliminate the translation component of the transformation and create a centered
|
||||
* transformation with the image center as the origin. Translation is ignored since it has no
|
||||
* effect on the size of the domain and will be restored later. */
|
||||
const float2 center = float2(float2(size) / 2.0f);
|
||||
/* Eliminate the translation component of the transformation. Translation is ignored since it has
|
||||
* no effect on the size of the domain and will be restored later. */
|
||||
const float3x3 transformation = float3x3(float2x2(domain.transformation));
|
||||
const float3x3 centered_transformation = math::from_origin_transform(transformation, center);
|
||||
|
||||
/* Translate the input such that it is centered in the virtual compositing space. */
|
||||
const float2 center_translation = -float2(size) / 2.0f;
|
||||
const float3x3 centered_transformation = math::translate(transformation, center_translation);
|
||||
|
||||
/* Transform each of the 4 corners of the image by the centered transformation. */
|
||||
const float2 transformed_lower_left_corner = math::transform_point(centered_transformation,
|
||||
|
||||
Reference in New Issue
Block a user