24 b.use_custom_socket_order();
25 b.allow_any_socket_order();
27 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
31 .structure_type(StructureType::Dynamic)
32 .align_with_previous();
38 .
description(
"The X position of the lower left corner of the crop region");
43 .
description(
"The Y position of the lower left corner of the crop region");
49 .description(
"The width of the crop region");
55 .description(
"The height of the crop region");
60 "Sets the areas outside of the crop region to be transparent instead of actually "
61 "cropping the size of the image");
91 if (this->
context().use_gpu()) {
132 output.allocate_texture(domain);
136 bool is_inside = texel.x >= bounds.min.x && texel.y >= bounds.min.y &&
137 texel.x < bounds.max.x && texel.y < bounds.max.y;
139 float4 color = is_inside ? float4(input.load_pixel<Color>(texel)) : float4(0.0f);
140 output.store_pixel(texel, Color(color));
147 if (this->
context().use_gpu()) {
219 this->
get_input(
"X").get_single_value_default<int>(), 0, input_size.x - 1);
221 this->
get_input(
"Y").get_single_value_default<int>(), 0, input_size.y - 1);
222 const int width =
math::max(1, this->
get_input(
"Width").get_single_value_default<int>());
223 const int height =
math::max(1, this->
get_input(
"Height").get_single_value_default<int>());
251 "Crops image to a smaller region, either making the cropped area transparent or resizing "
#define NODE_CLASS_DISTORT
#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 get_single_value_default() const
T load_pixel(const int2 &texel) 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 execute_image_crop_cpu()
void execute_alpha_crop_cpu()
void execute_alpha_crop_gpu()
Bounds< int2 > compute_cropping_bounds()
void execute_alpha_crop()
void execute_image_crop_gpu()
void execute_image_crop()
void node_register_type(bNodeType &ntype)
std::optional< Bounds< T > > intersect(const Bounds< T > &a, const Bounds< T > &b)
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)
T clamp(const T &a, const T &min, const T &max)
T max(const T &a, const T &b)
static void node_register()
static void node_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
void GPU_shader_uniform_2iv(gpu::Shader *sh, const char *name, const int data[2])
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
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