19 b.use_custom_socket_order();
20 b.allow_any_socket_order();
23 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
27 .structure_type(StructureType::Dynamic)
28 .align_with_previous();
35 "The number of samples used to compute the blur. The more samples the smoother the "
36 "result, but at the expense of more compute time. The actual number of samples is two "
37 "to the power of this input, so it increases exponentially");
41 .default_value({0.5f, 0.5f})
45 "The position at which the transformations pivot around. Defined in normalized "
46 "coordinates, so 0 means lower left corner and 1 means upper right corner of the image");
51 .description(
"The amount of rotation that the blur spans");
55 .
description(
"The amount of scaling that the blur spans");
58 b.add_panel(
"Translation"_ustr).default_closed(
false);
65 "The amount of translation that the blur spans in the specified direction relative to "
66 "the size of the image. Negative values indicate translation in the opposite direction");
70 .description(
"The angle that defines the direction of the translation");
88 if (this->
context().use_gpu()) {
144 output.allocate_texture(domain);
150 float current_sin = 0.0f;
151 float current_cos = 1.0f;
152 float current_scale = 1.0f;
158 for (
int i = 0; i < iterations; i++) {
162 float2 transformed_coordinates = coordinates;
163 transformed_coordinates -= origin;
164 transformed_coordinates /= current_scale;
165 transformed_coordinates -= current_translation;
166 transformed_coordinates = transformed_coordinates *
168 float2(-current_sin, current_cos));
169 transformed_coordinates += origin;
171 accumulated_color +=
float4(
174 current_scale += delta_scale;
175 current_translation += delta_translation;
179 float new_sin = current_sin * delta_rotation_cos + current_cos * delta_rotation_sin;
180 current_cos = current_cos * delta_rotation_cos - current_sin * delta_rotation_sin;
181 current_sin = new_sin;
184 output.store_pixel(texel,
Color(accumulated_color / iterations));
198 const float2 translation = rotation *
226 const int iterations = 2 << (this->
get_samples() - 1);
229 return math::min(iterations, upper_limit);
268 this->
get_input(
"Translation Amount").get_single_value_default<float>(), -1.0f, 1.0f);
297 ntype.
ui_name =
"Directional Blur";
#define NODE_CLASS_OP_FILTER
#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()
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
T sample_bilinear_zero(const float2 &coordinates) const
T get_single_value_default() const
void unbind_as_image() const
void bind_as_image(gpu::Shader *shader, const char *image_name, bool read=false) const
DeclType::Builder & add_input(UString name, UString identifier=""_ustr)
StructureType structure_type
float2 get_delta_translation()
NodeOperation(Context &context, const bNode &node)
float get_delta_rotation()
float get_translation_direction()
float get_translation_amount()
void node_register_type(bNodeType &ntype)
void compute_dispatch_threads_at_least(gpu::Shader *shader, int2 threads_range, int2 local_size=int2(16))
ColorSceneLinear4f< eAlpha::Premultiplied > Color
void parallel_for(const int2 range, const Function &function)
AngleRadianBase< float > AngleRadian
T cos(const AngleRadianBase< T > &a)
T clamp(const T &a, const T &min, const T &max)
T length(const VecBase< T, Size > &a)
T min(const T &a, const T &b)
T sin(const AngleRadianBase< T > &a)
T max(const T &a, const T &b)
MatT from_rotation(const RotationT &rotation)
static void node_declare(NodeDeclarationBuilder &b)
static void node_register()
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
MatBase< float, 2, 2 > float2x2
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
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_shader_uniform_1i(gpu::Shader *sh, const char *name, int value)
void GPU_shader_uniform_2fv(gpu::Shader *sh, const char *name, const float data[2])
void GPU_texture_extend_mode(gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
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