diff options
author | Omar Emara <mail@OmarEmara.dev> | 2022-10-20 17:31:35 +0300 |
---|---|---|
committer | Omar Emara <mail@OmarEmara.dev> | 2022-10-20 17:32:28 +0300 |
commit | 58e25f11ae9eb805dd857fae56be1d1a43710091 (patch) | |
tree | 50e7fe25fbf77f7ee16c42406d2debb1f2cd565f /source/blender/compositor/realtime_compositor/algorithms/intern/algorithm_parallel_reduction.cc | |
parent | 9d710374bda41359132f929286f5eea7340441b5 (diff) |
Realtime Compositor: Implement normalize node
This patch implements the normalize node for the realtime compositor.
Differential Revision: https://developer.blender.org/D16279
Reviewed By: Clement Foucault
Diffstat (limited to 'source/blender/compositor/realtime_compositor/algorithms/intern/algorithm_parallel_reduction.cc')
-rw-r--r-- | source/blender/compositor/realtime_compositor/algorithms/intern/algorithm_parallel_reduction.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/compositor/realtime_compositor/algorithms/intern/algorithm_parallel_reduction.cc b/source/blender/compositor/realtime_compositor/algorithms/intern/algorithm_parallel_reduction.cc index 139c58bc190..9672431992d 100644 --- a/source/blender/compositor/realtime_compositor/algorithms/intern/algorithm_parallel_reduction.cc +++ b/source/blender/compositor/realtime_compositor/algorithms/intern/algorithm_parallel_reduction.cc @@ -249,6 +249,25 @@ float maximum_luminance(Context &context, GPUTexture *texture, float3 luminance_ return maximum; } +float maximum_float_in_range(Context &context, + GPUTexture *texture, + float lower_bound, + float upper_bound) +{ + GPUShader *shader = context.shader_manager().get("compositor_maximum_float_in_range"); + GPU_shader_bind(shader); + + GPU_shader_uniform_1f(shader, "lower_bound", lower_bound); + GPU_shader_uniform_1f(shader, "upper_bound", upper_bound); + + float *reduced_value = parallel_reduction_dispatch(context, texture, shader, GPU_R32F); + const float maximum = *reduced_value; + MEM_freeN(reduced_value); + GPU_shader_unbind(); + + return maximum; +} + /* -------------------------------------------------------------------- * Minimum Reductions. */ @@ -268,4 +287,23 @@ float minimum_luminance(Context &context, GPUTexture *texture, float3 luminance_ return minimum; } +float minimum_float_in_range(Context &context, + GPUTexture *texture, + float lower_bound, + float upper_bound) +{ + GPUShader *shader = context.shader_manager().get("compositor_minimum_float_in_range"); + GPU_shader_bind(shader); + + GPU_shader_uniform_1f(shader, "lower_bound", lower_bound); + GPU_shader_uniform_1f(shader, "upper_bound", upper_bound); + + float *reduced_value = parallel_reduction_dispatch(context, texture, shader, GPU_R32F); + const float minimum = *reduced_value; + MEM_freeN(reduced_value); + GPU_shader_unbind(); + + return minimum; +} + } // namespace blender::realtime_compositor |