37 N_(
"Applies a recursive Gaussian blur that can be faster and more accurate in some cases, "
38 "but less accurate in other cases")},
43 N_(
"Applies a cubic Catmull-Rom filter")},
48 N_(
"Applies a cubic Mitchell-Netravali filter")},
49 {0,
nullptr, 0,
nullptr,
nullptr},
54 b.use_custom_socket_order();
55 b.allow_any_socket_order();
57 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
61 .structure_type(StructureType::Dynamic)
62 .align_with_previous();
69 .structure_type(StructureType::Dynamic);
74 b.add_input<
decl::Bool>(
"Extend Bounds"_ustr).default_value(
false);
78 "Use faster approximation by blurring along the horizontal and vertical directions "
130 if (!size.is_single_value()) {
161 if (this->
context().use_gpu()) {
171 if (this->
context().use_gpu()) {
194 output.allocate_texture(domain);
212 output.allocate_texture(domain);
215 float4 accumulated_color = float4(0.0f);
218 float4 center_color = float4(input.load_pixel_extended<Color>(texel));
219 accumulated_color += center_color * weights.load_pixel<float>(int2(0));
221 int2 weights_size = weights.domain().data_size;
227 for (int x = 1; x < weights_size.x; x++) {
228 float weight = weights.load_pixel<float>(int2(x, 0));
229 accumulated_color += float4(input.load_pixel_extended<Color>(texel + int2(x, 0))) * weight;
230 accumulated_color += float4(input.load_pixel_extended<Color>(texel + int2(-x, 0))) *
238 for (
int y = 1;
y < weights_size.y;
y++) {
249 for (
int y = 1;
y < weights_size.y;
y++) {
250 for (
int x = 1;
x < weights_size.x;
x++) {
263 output.store_pixel(texel,
Color(accumulated_color));
278 if (this->
context().use_gpu()) {
289 if (this->
context().use_gpu()) {
301 const Result &weights =
context().cache_manager().symmetric_blur_weights.get(
312 output.allocate_texture(domain);
327 const Result &weights = this->
context().cache_manager().symmetric_blur_weights.get(
331 output.allocate_texture(domain);
334 float4 accumulated_color = float4(0.0f);
335 float4 accumulated_weight = float4(0.0f);
337 const float2 size = math::max(float2(0.0f), size_input.load_pixel_extended<float2>(texel));
338 int2 radius = int2(math::ceil(size));
339 float2 coordinates_scale = float2(1.0f) / (size + float2(1.0f));
342 float4 center_color = float4(input.load_pixel_extended<Color>(texel));
343 float center_weight = weights.load_pixel<float>(int2(0));
344 accumulated_color += center_color * center_weight;
345 accumulated_weight += center_weight;
351 for (int x = 1; x <= radius.x; x++) {
352 float weight_coordinates = (x + 0.5f) * coordinates_scale.x;
353 float weight = weights.sample_bilinear_extended<float>(float2(weight_coordinates, 0.0f));
354 accumulated_color += float4(input.load_pixel_extended<Color>(texel + int2(x, 0))) * weight;
355 accumulated_color += float4(input.load_pixel_extended<Color>(texel + int2(-x, 0))) *
357 accumulated_weight += weight * 2.0f;
364 for (
int y = 1;
y <= radius.y;
y++) {
365 float weight_coordinates = (
y + 0.5f) * coordinates_scale.y;
370 accumulated_weight += weight * 2.0f;
377 for (
int y = 1;
y <= radius.y;
y++) {
378 for (
int x = 1;
x <= radius.x;
x++) {
389 accumulated_weight += weight * 4.0f;
395 output.store_pixel(texel,
Color(accumulated_color));
412 if (!size.is_single_value()) {
453 return this->
get_input(
"Separable").get_single_value_default<
bool>();
458 return this->
get_input(
"Extend Bounds").get_single_value_default<
bool>();
#define NODE_CLASS_OP_FILTER
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define BLI_assert_unreachable()
StaticCacheManager & cache_manager()
Result create_result(ResultType type, ResultPrecision precision)
gpu::Shader * get_shader(const char *info_name, ResultPrecision precision)
NodeOperation(Context &context, const bNode &node)
Result & get_result(StringRef identifier)
Context & context() const
Result & get_input(StringRef identifier) const
bool is_single_value() const
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
SymmetricBlurWeightsContainer symmetric_blur_weights
Result & get(Context &context, math::FilterKernel type, float2 radius)
StructureType structure_type
NodeOperation(Context &context, const bNode &node)
void execute_variable_size_cpu(const Result &input, const Result &size_input, Result &output)
bool use_separable_filter()
CMPNodeBlurType get_type()
void execute_constant_size_gpu(const Result &input, Result &output)
float2 compute_maximum_blur_size()
void execute_variable_size(const Result &input, const Result &size, Result &output)
void execute_constant_size(const Result &input, Result &output)
void execute_constant_size_cpu(const Result &input, Result &output)
void execute_variable_size_gpu(const Result &input, const Result &size_input, Result &output)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
void compute_dispatch_threads_at_least(gpu::Shader *shader, int2 threads_range, int2 local_size=int2(16))
float2 maximum_float2(Context &context, const Result &input)
void symmetric_separable_blur(Context &context, const Result &input, Result &output, const float2 &radius, const math::FilterKernel filter_type=math::FilterKernel::Gauss, const bool extend_bounds=false)
ColorSceneLinear4f< eAlpha::Premultiplied > Color
void pad(Context &context, const Result &input, Result &output, const int2 size, const PaddingMethod padding_method)
void recursive_gaussian_blur(Context &context, const Result &input, Result &output, const float2 &radius, const bool extend_bounds=false)
void parallel_for(const int2 range, const Function &function)
T safe_divide(const T &a, const T &b)
T max(const T &a, const T &b)
static math::FilterKernel blur_type_to_kernel(CMPNodeBlurType type)
static const EnumPropertyItem type_items[]
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
static void node_register()
static void node_declare(NodeDeclarationBuilder &b)
static void node_init(bNodeTree *, bNode *node)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ CMP_NODE_BLUR_TYPE_GAUSS
@ CMP_NODE_BLUR_TYPE_CATROM
@ CMP_NODE_BLUR_TYPE_CUBIC
@ CMP_NODE_BLUR_TYPE_FAST_GAUSS
@ CMP_NODE_BLUR_TYPE_QUAD
@ CMP_NODE_BLUR_TYPE_TENT
@ CMP_NODE_BLUR_TYPE_MITCH
BMesh const char void * data
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
void cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeGetCompositorOperationFunction get_compositor_operation
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare