19 b.use_custom_socket_order();
20 b.allow_any_socket_order();
22 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
26 .structure_type(StructureType::Dynamic)
27 .align_with_previous();
30 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
31 .structure_type(StructureType::Dynamic);
36 .description(
"The size of the blur in pixels");
41 "Pixels are considered in the blur area if the average difference between their "
42 "determinator and the determinator of the center pixel is less than this threshold");
56 this->get_threshold() == 0.0f)
73 if (this->
context().use_gpu()) {
118 output.allocate_texture(domain);
121 float4 center_determinator = float4(determinator_image.load_pixel<Color>(texel));
126 float accumulated_weight = 0.0f;
127 float4 accumulated_color = float4(0.0f);
128 for (int y = -radius; y <= radius; y++) {
129 for (int x = -radius; x <= radius; x++) {
130 float4 determinator = float4(
131 determinator_image.load_pixel_extended<Color>(texel + int2(x, y)));
132 float difference = math::dot(math::abs(center_determinator - determinator).xyz(),
136 if (difference < threshold) {
137 accumulated_weight += 1.0f;
138 accumulated_color += float4(input.load_pixel_extended<Color>(texel + int2(x, y)));
146 float4 color = (accumulated_weight != 0.0f) ? (accumulated_color / accumulated_weight) :
159 return math::max(0.0f, this->
get_input(
"Threshold").get_single_value_default<float>());
173 ntype.
ui_name =
"Bilateral Blur";
174 ntype.
ui_description =
"Adaptively blur image, while retaining sharp edges";
#define NODE_CLASS_OP_FILTER
#define CMP_NODE_BILATERALBLUR
#define NOD_REGISTER_NODE(REGISTER_FUNC)
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
virtual Domain compute_domain()
void share_data(const Result &source)
bool is_single_value() const
void allocate_texture(const Domain domain, const bool from_pool=true, const std::optional< ResultStorageType > storage_type=std::nullopt)
void unbind_as_texture() const
void bind_as_texture(gpu::Shader *shader, const char *texture_name) const
void unbind_as_image() const
void bind_as_image(gpu::Shader *shader, const char *image_name, bool read=false) const
StructureType structure_type
NodeOperation(Context &context, const bNode &node)
void node_register_type(bNodeType &ntype)
void compute_dispatch_threads_at_least(gpu::Shader *shader, int2 threads_range, int2 local_size=int2(16))
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 parallel_for(const int2 range, const Function &function)
T max(const T &a, const T &b)
static void node_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
static void node_register()
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_1i(gpu::Shader *sh, const char *name, int value)
void GPU_shader_uniform_1f(gpu::Shader *sh, const char *name, float value)
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
const char * enum_name_legacy
NodeDeclareFunction declare