diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2013-12-04 19:05:56 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2013-12-04 19:05:56 +0400 |
commit | 67134a7bf689279785e2e40b29cd24243813998b (patch) | |
tree | 6c3a117459901d455d52726bd7bddd3e931e9650 /source/blender/compositor/operations/COM_MapUVOperation.h | |
parent | 04e434cd81edf942289f7094bc5fdc3ab8846259 (diff) |
Fix for EWA (elliptical weighted average) sampling in the compositor.
EWA sampling is designed for downsampling images, i.e. scaling down the size of
input image pixels, which happens regularly in compositing. While the standard
sampling methods (linear, cubic) work reasonably well for linear
transformations, they don't yield good results in non-linear cases like
perspective projection or arbitrary displacement. EWA sampling is comparable to
mipmapping, but avoids problems with discontinuities.
To work correctly the EWA algorithm needs partial derivatives of the mapping
functions which convert output pixel coordinates back into the input image
space (2x2 Jacobian matrix). With these derivatives the EWA algorithm
projects ellipses into the input space and accumulates colors over their
area. This calculation was not done correctly in the compositor, only the
derivatives du/dx and dv/dy were calculation, basically this means it only
worked for non-rotated input images.
The patch introduces full derivative calculations du/dx, du/dy, dv/dx, dv/dy for
the 3 nodes which use EWA sampling currently: PlaneTrackWarp, MapUV and
Displace. In addition the calculation of ellipsis area and axis-aligned
bounding boxes has been fixed.
For the MapUV and Displace nodes the derivatives have to be estimated by
evaluating the UV/displacement inputs with 1-pixel offsets, which can still have
problems on discontinuities and sub-pixel variations. These potential problems
can only be alleviated by more radical design changes in the compositor
functions, which are out of scope for now. Basically the values passed to the
UV/Displacement inputs would need to be associated with their 1st order
derivatives, which requires a general approach to derivatives in all nodes.
Diffstat (limited to 'source/blender/compositor/operations/COM_MapUVOperation.h')
-rw-r--r-- | source/blender/compositor/operations/COM_MapUVOperation.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.h b/source/blender/compositor/operations/COM_MapUVOperation.h index fe8bfd2a9ac..796ee952607 100644 --- a/source/blender/compositor/operations/COM_MapUVOperation.h +++ b/source/blender/compositor/operations/COM_MapUVOperation.h @@ -46,7 +46,9 @@ public: * the inner loop of this program */ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); - + + void pixelTransform(const float xy[2], float r_uv[2], float r_deriv[2][2], float &r_alpha); + /** * Initialize the execution */ @@ -58,5 +60,9 @@ public: void deinitExecution(); void setAlpha(float alpha) { this->m_alpha = alpha; } + +private: + bool read_uv(float x, float y, float &r_u, float &r_v, float &r_alpha); }; + #endif |