This patch delays applying transformations until realization happens on some other domain. Currently, transformations are applied immediately at the point of transform nodes, this is problematic for a few reasons: - If that result was then realized on some other domain, interpolation will have happened two times, at the transform nodes and at the node that required realization, causing less than ideal precision issues. - It is not possible to repeat or extend a rotated result because its empty areas will be zero filled, leaving gaps in its extension. So this patch is a prerequisite for #132371 if we want full support for repetition. - Doing inverse transformations will introduce interpolation artifacts which might be undesirable. Inverse transformations might be used to do pixelation for instance, so this change will be undesirable in this case. But we decided that this is not a use case that we want to support, and we added explicit pixel size control to the pixelate node as an alternative. So this has four implications, two that might be considered bad: - Transformations will now be higher quality and more precise. - Repetition and other boundary extension methods will now be possible. - Downsampling then upsampling will no longer produce pixelated results. - Realization might happen multiple times with identical results in some cases. The last point not a big issue, since domain realization is not a big bottleneck in the compositor, and the plan is to move realization into pixel operations, so it will even be more efficient than it is now. Pull Request: https://projects.blender.org/blender/blender/pulls/133158
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include "BLI_math_matrix.hh"
|
|
#include "BLI_math_matrix_types.hh"
|
|
#include "BLI_math_vector_types.hh"
|
|
|
|
#include "COM_domain.hh"
|
|
|
|
namespace blender::compositor {
|
|
|
|
Domain::Domain(const int2 &size) : size(size), transformation(float3x3::identity()) {}
|
|
|
|
Domain::Domain(const int2 &size, const float3x3 &transformation)
|
|
: size(size), transformation(transformation)
|
|
{
|
|
}
|
|
|
|
void Domain::transform(const float3x3 &input_transformation)
|
|
{
|
|
transformation = input_transformation * transformation;
|
|
}
|
|
|
|
Domain Domain::identity()
|
|
{
|
|
return Domain(int2(1), float3x3::identity());
|
|
}
|
|
|
|
bool Domain::is_equal(const Domain &a, const Domain &b, const float epsilon)
|
|
{
|
|
return a.size == b.size && math::is_equal(a.transformation, b.transformation, epsilon);
|
|
}
|
|
|
|
bool operator==(const Domain &a, const Domain &b)
|
|
{
|
|
return a.size == b.size && a.transformation == b.transformation;
|
|
}
|
|
|
|
bool operator!=(const Domain &a, const Domain &b)
|
|
{
|
|
return !(a == b);
|
|
}
|
|
|
|
} // namespace blender::compositor
|