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++) {
53 float2((
float(i) + 0.5f) /
float(radius + 1), 0.0f));
56 accumulated_weight += weight * 2.0f;
61 output.store_pixel(
int2(texel.y, texel.x),
Color(accumulated_color / accumulated_weight));
68 const int weights_resolution,
71 gpu::Shader *
shader = context.get_shader(
"compositor_symmetric_separable_blur_variable_size");
78 const Result &weights = context.cache_manager().symmetric_separable_blur_weights.get(
79 context, filter_type, weights_resolution);
84 radius.bind_as_texture(
shader,
"radius_tx");
98 output.allocate_texture(transposed_domain);
106 radius.unbind_as_texture();
115 const int weights_resolution,
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,
146 if (context.use_gpu()) {
153 const Result &original_input,
154 const Result &horizontal_pass_result,
157 const int weights_resolution,
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);
173 radius.bind_as_texture(
shader,
"radius_tx");
176 output.allocate_texture(domain);
187 radius.unbind_as_texture();
191 const Result &original_input,
192 const Result &horizontal_pass_result,
195 const int weights_resolution,
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,
215 if (context.use_gpu()) {
218 horizontal_pass_result,
227 horizontal_pass_result,
239 const int weights_resolution,
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();
T sample_bilinear_extended(const float2 &coordinates) const
void unbind_as_texture() const
static ResultType type(gpu::TextureFormat format)
void bind_as_texture(gpu::Shader *shader, const char *texture_name) const
T load_pixel_extended(const int2 &texel) const
T load_pixel(const int2 &texel) 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))
ColorSceneLinear4f< eAlpha::Premultiplied > Color
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 math::FilterKernel filter_type=math::FilterKernel::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)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ GPU_SAMPLER_EXTEND_MODE_EXTEND
void GPU_shader_uniform_1b(gpu::Shader *sh, const char *name, bool value)
void GPU_texture_filter_mode(gpu::Texture *texture, bool use_filter)
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_texture_extend_mode(gpu::Texture *texture, GPUSamplerExtendMode extend_mode)