22 const Result &radius_input,
25 const bool is_vertical_pass)
31 float accumulated_weight = 0.0f;
37 accumulated_color += center_color * center_weight;
38 accumulated_weight += center_weight;
44 radius_input.
load_pixel<
float>(is_vertical_pass ?
int2(texel.y, texel.x) : texel));
50 for (
int i = 1;
i <= radius;
i++) {
54 accumulated_color +=
input.load_pixel_extended<
float4>(texel +
int2(
i, 0)) * weight;
55 accumulated_color +=
input.load_pixel_extended<
float4>(texel +
int2(-
i, 0)) * weight;
56 accumulated_weight += weight * 2.0f;
61 output.store_pixel(
int2(texel.y, texel.x), accumulated_color / accumulated_weight);
68 const int weights_resolution,
69 const int filter_type)
71 gpu::Shader *shader = context.get_shader(
"compositor_symmetric_separable_blur_variable_size");
76 input.bind_as_texture(shader,
"input_tx");
78 const Result &weights = context.cache_manager().symmetric_separable_blur_weights.get(
79 context, filter_type, weights_resolution);
98 output.allocate_texture(transposed_domain);
99 output.bind_as_image(shader,
"output_img");
104 input.unbind_as_texture();
115 const int weights_resolution,
116 const int filter_type)
118 const Result &weights = context.cache_manager().symmetric_separable_blur_weights.get(
119 context, filter_type, weights_resolution);
133 output.allocate_texture(transposed_domain);
143 const int weights_resolution,
144 const int filter_type)
146 if (context.use_gpu()) {
153 const Result &original_input,
154 const Result &horizontal_pass_result,
157 const int weights_resolution,
158 const int filter_type)
160 gpu::Shader *shader = context.get_shader(
"compositor_symmetric_separable_blur_variable_size");
167 const Result &weights = context.cache_manager().symmetric_separable_blur_weights.get(
168 context, filter_type, weights_resolution);
176 output.allocate_texture(domain);
177 output.bind_as_image(shader,
"output_img");
191 const Result &original_input,
192 const Result &horizontal_pass_result,
195 const int weights_resolution,
196 const int filter_type)
198 const Result &weights = context.cache_manager().symmetric_separable_blur_weights.get(
199 context, filter_type, weights_resolution);
202 output.allocate_texture(domain);
208 const Result &original_input,
209 const Result &horizontal_pass_result,
212 const int weights_resolution,
213 const int filter_type)
215 if (context.use_gpu()) {
218 horizontal_pass_result,
227 horizontal_pass_result,
239 const int weights_resolution,
240 const int filter_type)
245 context,
input, radius, weights_resolution, filter_type);
247 context,
input, horizontal_pass_result, radius,
output, weights_resolution, filter_type);
248 horizontal_pass_result.
release();
void GPU_shader_uniform_1b(blender::gpu::Shader *sh, const char *name, bool value)
void GPU_shader_bind(blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_texture_extend_mode(blender::gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
@ GPU_SAMPLER_EXTEND_MODE_EXTEND
void GPU_texture_filter_mode(blender::gpu::Texture *texture, bool use_filter)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void unbind_as_texture() const
void bind_as_texture(gpu::Shader *shader, const char *texture_name) const
const Domain & domain() const
T load_pixel(const int2 &texel) const
float4 sample_bilinear_extended(const float2 &coordinates) const
static void vertical_pass_cpu(Context &context, const Result &original_input, const Result &horizontal_pass_result, Result &output, const int distance, const int falloff_type)
void compute_dispatch_threads_at_least(gpu::Shader *shader, int2 threads_range, int2 local_size=int2(16))
static void vertical_pass(Context &context, const Result &original_input, const Result &horizontal_pass_result, Result &output, const int distance, const int falloff_type)
static Result horizontal_pass_cpu(Context &context, const Result &input, const int distance, const int falloff_type)
static Result horizontal_pass_gpu(Context &context, const Result &input, const int distance, const int falloff_type)
static Result horizontal_pass(Context &context, const Result &input, const int distance, const int falloff_type)
void symmetric_separable_blur_variable_size(Context &context, const Result &input, const Result &radius, Result &output, const int weights_resolution=128, const int filter_type=R_FILTER_GAUSS)
void parallel_for(const int2 range, const Function &function)
static void vertical_pass_gpu(Context &context, const Result &original_input, const Result &horizontal_pass_result, Result &output, const int distance, const int falloff_type)
static void blur_pass(Context &context, const Result &input, Result &output, const float sigma)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2