Compositor: Remove Max Blur option from Bokeh Blur node

This patch removes the Max Blur option from the Bokeh Blur node. The
reasoning is as follows.

- The option was unused in case of non-variable sized blur, which was
  the default, so the option did nothing for the default case of the
  node.
- The option was originally introduced to define the search window of
  variable size blur. This is no longer the case, since we compute the
  search window dynamically from the input using parallel reduction,
  which is now very fast. So currently, it only works as an upper limit.
- The node options will be exposed as inputs, so the user will see two
  inputs that control the radius, which can be confusing for users that
  are not experienced.
- The plan is to make the node take absolute pixel sizes in the future,
  instead of the arbitrary relative size now in place, which would make
  it very easy for the user to impose such limits manually.

It is difficult to version this change, since the size is relative to
the image size, while max blur is in pixels. But we assume the user
chose a sufficiently large max blur for the node to be useful, so the
composite should not be expected to be drastically different.

Pull Request: https://projects.blender.org/blender/blender/pulls/138659
This commit is contained in:
Omar Emara
2025-05-09 12:47:27 +02:00
committed by Omar Emara
parent 0b97a13eaa
commit f3275f5d12
2 changed files with 3 additions and 27 deletions

View File

@@ -9717,22 +9717,11 @@ static void def_cmp_bokehblur(BlenderRNA * /*brna*/, StructRNA *srna)
prop, "Extend Bounds", "Extend bounds of the input image to fully fit blurred image");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
# if 0
prop = RNA_def_property(srna, "f_stop", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, nullptr, "custom3");
RNA_def_property_range(prop, 0.0f, 128.0f);
RNA_def_property_ui_text(
prop,
"F-Stop",
"Amount of focal blur, 128 (infinity) is perfect focus, half the value doubles "
"the blur radius");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
# endif
prop = RNA_def_property(srna, "blur_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, nullptr, "custom4");
RNA_def_property_range(prop, 0.0f, 10000.0f);
RNA_def_property_ui_text(prop, "Max Blur", "Blur limit, maximum CoC radius");
RNA_def_property_ui_text(
prop, "Max Blur", "Blur limit, maximum CoC radius. (Deprecated: Unused.)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}

View File

@@ -43,15 +43,8 @@ static void cmp_node_bokehblur_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>("Image");
}
static void node_composit_init_bokehblur(bNodeTree * /*ntree*/, bNode *node)
{
node->custom3 = 4.0f;
node->custom4 = 16.0f;
}
static void node_composit_buts_bokehblur(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
layout->prop(ptr, "blur_max", UI_ITEM_R_SPLIT_EMPTY_NAME, std::nullopt, ICON_NONE);
layout->prop(ptr, "use_extended_bounds", UI_ITEM_R_SPLIT_EMPTY_NAME, std::nullopt, ICON_NONE);
}
@@ -346,7 +339,7 @@ class BokehBlurOperation : public NodeOperation {
const float maximum_size = maximum_float(context(), input_size);
const float base_size = compute_blur_radius();
return math::clamp(int(maximum_size * base_size), 0, get_max_size());
return math::max(0, int(maximum_size * base_size));
}
float compute_blur_radius()
@@ -387,11 +380,6 @@ class BokehBlurOperation : public NodeOperation {
{
return bnode().custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS;
}
int get_max_size()
{
return int(bnode().custom4);
}
};
static NodeOperation *get_compositor_operation(Context &context, DNode node)
@@ -416,7 +404,6 @@ void register_node_type_cmp_bokehblur()
ntype.nclass = NODE_CLASS_OP_FILTER;
ntype.declare = file_ns::cmp_node_bokehblur_declare;
ntype.draw_buttons = file_ns::node_composit_buts_bokehblur;
ntype.initfunc = file_ns::node_composit_init_bokehblur;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
blender::bke::node_register_type(ntype);