Blender Git Commit Log
Git Commits -> Revision 67134a7
Revision 67134a7 by Lukas Toenne (master) December 4, 2013, 15:05 (GMT) |
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. |
Commit Details:
Full Hash: 67134a7bf689279785e2e40b29cd24243813998b
Parent Commit: 04e434c
Lines Changed: +326, -276
13 Modified Paths:
/source/blender/blenlib/BLI_math_geom.h (+2, -0) (Diff)
/source/blender/blenlib/intern/math_geom.c (+33, -0) (Diff)
/source/blender/compositor/intern/COM_MemoryBuffer.cpp (+83, -111) (Diff)
/source/blender/compositor/intern/COM_MemoryBuffer.h (+1, -1) (Diff)
/source/blender/compositor/intern/COM_SocketReader.h (+2, -2) (Diff)
/source/blender/compositor/operations/COM_DisplaceOperation.cpp (+81, -43) (Diff)
/source/blender/compositor/operations/COM_DisplaceOperation.h (+6, -1) (Diff)
/source/blender/compositor/operations/COM_MapUVOperation.cpp (+83, -33) (Diff)
/source/blender/compositor/operations/COM_MapUVOperation.h (+7, -1) (Diff)
/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp (+22, -79) (Diff)
/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h (+1, -2) (Diff)
/source/blender/compositor/operations/COM_ReadBufferOperation.cpp (+4, -2) (Diff)
/source/blender/compositor/operations/COM_ReadBufferOperation.h (+1, -1) (Diff)
/source/blender/blenlib/intern/math_geom.c (+33, -0) (Diff)
/source/blender/compositor/intern/COM_MemoryBuffer.cpp (+83, -111) (Diff)
/source/blender/compositor/intern/COM_MemoryBuffer.h (+1, -1) (Diff)
/source/blender/compositor/intern/COM_SocketReader.h (+2, -2) (Diff)
/source/blender/compositor/operations/COM_DisplaceOperation.cpp (+81, -43) (Diff)
/source/blender/compositor/operations/COM_DisplaceOperation.h (+6, -1) (Diff)
/source/blender/compositor/operations/COM_MapUVOperation.cpp (+83, -33) (Diff)
/source/blender/compositor/operations/COM_MapUVOperation.h (+7, -1) (Diff)
/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp (+22, -79) (Diff)
/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h (+1, -2) (Diff)
/source/blender/compositor/operations/COM_ReadBufferOperation.cpp (+4, -2) (Diff)
/source/blender/compositor/operations/COM_ReadBufferOperation.h (+1, -1) (Diff)