diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-09-23 13:42:11 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2014-09-23 13:42:11 +0400 |
commit | dbb9eba0fb81b41c15deccc97a6d7c2d9825cb60 (patch) | |
tree | 84f8282e425abd6b608d5b518d724b2dcda75b4c | |
parent | d7ddb941a07b806decc867bf58e3ec84d2ec1d41 (diff) |
Fixed border extension for the sunbeams node.
This ensures that the beams color does not darken along borders,
by using the last valid color of the ray as the border color (extending
colors in the direction of the source point).
m--------- | release/datafiles/locale | 0 | ||||
m--------- | release/scripts/addons | 0 | ||||
m--------- | release/scripts/addons_contrib | 0 | ||||
m--------- | scons | 0 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_SunBeamsOperation.cpp | 27 |
5 files changed, 17 insertions, 10 deletions
diff --git a/release/datafiles/locale b/release/datafiles/locale -Subproject 5ea1456cf5bf9caa32d4988284cc0b75637dd45 +Subproject 18bf273c38b0d52429274159f1d4d4d00be59e3 diff --git a/release/scripts/addons b/release/scripts/addons -Subproject 59ff66fa7aca6a56dfa516ee4a456428516d2c6 +Subproject 655cd369b4b34e2969a3b167394e00caf0fde4b diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib -Subproject 9c1b7252bb510cc527c4ef2fd5aa3b586d095e9 +Subproject 8f33ffcebed445755d3453b8f486306bcf2b142 diff --git a/scons b/scons -Subproject 1ec93106c40fab0c339d09c7ed9897c85ddf3da +Subproject 625d446ae8996ff1b3d660c44e2827fc832cf12 diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp index 5caaff7d975..bcef652a8b5 100644 --- a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp +++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp @@ -138,6 +138,7 @@ struct BufferLineAccumulator { int x, y, num; float v, dv; float falloff_factor; + float border[4]; if ((int)pt_ofs[0] == 0 && (int)pt_ofs[1] == 0) { copy_v4_v4(output, input->getBuffer() + COM_NUMBER_OF_CHANNELS * ((int)source[0] + input->getWidth() * (int)source[1])); @@ -146,19 +147,26 @@ struct BufferLineAccumulator { /* initialise the iteration variables */ float *buffer = init_buffer_iterator(input, source, pt_ofs, dist_min, dist_max, x, y, num, v, dv, falloff_factor); - - int tot = 0; + zero_v3(border); + border[3] = 1.0f; /* v_local keeps track of when to decrement v (see below) */ float v_local = v - floorf(v); for (int i = 0; i < num; i++) { - /* range check, abort when running beyond the image border */ - if (x < rect.xmin || x >= rect.xmax || y < rect.ymin || y >= rect.ymax) - break; - - float f = 1.0f - (float)i * falloff_factor; - madd_v4_v4fl(output, buffer, buffer[3] * f * f); + float weight = 1.0f - (float)i * falloff_factor; + weight *= weight; + + /* range check, use last valid color when running beyond the image border */ + if (x >= rect.xmin && x < rect.xmax && y >= rect.ymin && y < rect.ymax) { + madd_v4_v4fl(output, buffer, buffer[3] * weight); + /* use as border color in case subsequent pixels are out of bounds */ + copy_v4_v4(border, buffer); + } + else { + madd_v4_v4fl(output, border, border[3] * weight); + } + /* TODO implement proper filtering here, see * http://en.wikipedia.org/wiki/Lanczos_resampling * http://en.wikipedia.org/wiki/Sinc_function @@ -166,9 +174,8 @@ struct BufferLineAccumulator { * using lanczos with x = distance from the line segment, * normalized to a == 0.5f, could give a good result * - * for now just count samples and divide equally at the end ... + * for now just divide equally at the end ... */ - tot++; /* decrement u */ x -= fxx; |