diff options
author | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-23 16:30:31 +0300 |
---|---|---|
committer | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-23 18:08:45 +0300 |
commit | daa7c59e38c8fe464004b3becd6956b880c38c92 (patch) | |
tree | c579e1eb7908bc24429fad527b9ae58fda4c67d7 /source/blender/blenlib/intern/math_base_inline.c | |
parent | 344aca3b1bf2718904455ea6cef1ffd8bedf51a6 (diff) |
Compositor: Full frame Bokeh Blur and Blur nodes
Adds full frame implementation to these nodes operations.
When enabling "extend bounds" node option, tiled implementation
result is slightly different because it's using `TranslateOperation`
with bilinear sampling for centering.
Full frame always uses nearest to don't lose image quality.
It has the disadvantage of causing image jiggling on backdrop
when switching size values as it's not pixel perfect.
This is fixed by rounding to even.
No functional changes.
Part of T88150.
Reviewed By: jbakker
Differential Revision: https://developer.blender.org/D12167
Diffstat (limited to 'source/blender/blenlib/intern/math_base_inline.c')
-rw-r--r-- | source/blender/blenlib/intern/math_base_inline.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index a80c495ecf3..983fd3b6543 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -363,6 +363,14 @@ MINLINE signed char round_db_to_char_clamp(double a){ #undef _round_clamp_fl_impl #undef _round_clamp_db_impl +/** + * Round to closest even number, halfway cases are rounded away from zero. + */ +MINLINE float round_to_even(float f) +{ + return roundf(f * 0.5f) * 2.0f; +} + /* integer division that rounds 0.5 up, particularly useful for color blending * with integers, to avoid gradual darkening when rounding down */ MINLINE int divide_round_i(int a, int b) |