diff options
author | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-10 16:23:47 +0300 |
---|---|---|
committer | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-10 17:16:22 +0300 |
commit | 0116a567dd06a4d53aa8d0117e49841963923742 (patch) | |
tree | 61eab88fa774cbcf3922d6df04b12145013e47e2 /source/blender/compositor/operations/COM_SunBeamsOperation.cc | |
parent | 6c0c766bcaa013007e12f2fd3e308d83cd95594c (diff) |
Compositor: Full frame Sun Beams node
Adds full frame implementation to this node operation.
No functional changes.
Reviewed By: jbakker
Differential Revision: https://developer.blender.org/D11694
Diffstat (limited to 'source/blender/compositor/operations/COM_SunBeamsOperation.cc')
-rw-r--r-- | source/blender/compositor/operations/COM_SunBeamsOperation.cc | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cc b/source/blender/compositor/operations/COM_SunBeamsOperation.cc index bd82b6397ad..ad96e3a02ba 100644 --- a/source/blender/compositor/operations/COM_SunBeamsOperation.cc +++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cc @@ -30,7 +30,7 @@ SunBeamsOperation::SunBeamsOperation() this->flags.complex = true; } -void SunBeamsOperation::initExecution() +void SunBeamsOperation::calc_rays_common_data() { /* convert to pixels */ this->m_source_px[0] = this->m_data.source[0] * this->getWidth(); @@ -38,6 +38,11 @@ void SunBeamsOperation::initExecution() this->m_ray_length_px = this->m_data.ray_length * MAX2(this->getWidth(), this->getHeight()); } +void SunBeamsOperation::initExecution() +{ + calc_rays_common_data(); +} + /** * Defines a line accumulator for a specific sector, * given by the four matrix entries that rotate from buffer space into the sector @@ -140,7 +145,7 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator { falloff_factor = dist_max > dist_min ? dr / (float)(dist_max - dist_min) : 0.0f; - float *iter = input->getBuffer() + COM_DATA_TYPE_COLOR_CHANNELS * (x + input->getWidth() * y); + float *iter = input->getBuffer() + input->get_coords_offset(x, y); return iter; } @@ -159,7 +164,6 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator { float dist_max) { const rcti &rect = input->get_rect(); - int buffer_width = input->getWidth(); int x, y, num; float v, dv; float falloff_factor; @@ -168,9 +172,7 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator { zero_v4(output); if ((int)(co[0] - source[0]) == 0 && (int)(co[1] - source[1]) == 0) { - copy_v4_v4(output, - input->getBuffer() + COM_DATA_TYPE_COLOR_CHANNELS * - ((int)source[0] + input->getWidth() * (int)source[1])); + copy_v4_v4(output, input->get_elem(source[0], source[1])); return; } @@ -210,7 +212,7 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator { /* decrement u */ x -= fxu; y -= fyu; - buffer -= (fxu + fyu * buffer_width) * COM_DATA_TYPE_COLOR_CHANNELS; + buffer -= fxu * input->elem_stride + fyu * input->row_stride; /* decrement v (in steps of dv < 1) */ v_local -= dv; @@ -219,7 +221,7 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator { x -= fxv; y -= fyv; - buffer -= (fxv + fyv * buffer_width) * COM_DATA_TYPE_COLOR_CHANNELS; + buffer -= fxv * input->elem_stride + fyv * input->row_stride; } } @@ -356,4 +358,39 @@ bool SunBeamsOperation::determineDependingAreaOfInterest(rcti *input, return NodeOperation::determineDependingAreaOfInterest(&rect, readOperation, output); } +void SunBeamsOperation::get_area_of_interest(const int input_idx, + const rcti &output_area, + rcti &r_input_area) +{ + BLI_assert(input_idx == 0); + UNUSED_VARS(input_idx); + calc_rays_common_data(); + + r_input_area = output_area; + /* Enlarges the rect by moving each corner toward the source. + * This is the maximum distance that pixels can influence each other + * and gives a rect that contains all possible accumulated pixels. */ + calc_ray_shift(&r_input_area, output_area.xmin, output_area.ymin, m_source_px, m_ray_length_px); + calc_ray_shift(&r_input_area, output_area.xmin, output_area.ymax, m_source_px, m_ray_length_px); + calc_ray_shift(&r_input_area, output_area.xmax, output_area.ymin, m_source_px, m_ray_length_px); + calc_ray_shift(&r_input_area, output_area.xmax, output_area.ymax, m_source_px, m_ray_length_px); +} + +void SunBeamsOperation::update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span<MemoryBuffer *> inputs) +{ + MemoryBuffer *input = inputs[0]; + float coords[2]; + for (int y = area.ymin; y < area.ymax; y++) { + coords[1] = y; + float *out_elem = output->get_elem(area.xmin, y); + for (int x = area.xmin; x < area.xmax; x++) { + coords[0] = x; + accumulate_line(input, out_elem, coords, m_source_px, 0.0f, m_ray_length_px); + out_elem += output->elem_stride; + } + } +} + } // namespace blender::compositor |