30 b.use_custom_socket_order();
31 b.allow_any_socket_order();
33 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
36 b.add_output<
decl::Color>(
"Image").structure_type(StructureType::Dynamic).align_with_previous();
42 .
description(
"The X position of the lower left corner of the crop region");
47 .
description(
"The Y position of the lower left corner of the crop region");
62 "Sets the areas outside of the crop region to be transparent instead of actually "
63 "cropping the size of the image");
93 if (this->
context().use_gpu()) {
138 bool is_inside = texel.x >= bounds.min.x && texel.y >= bounds.min.y &&
139 texel.x < bounds.max.x && texel.y < bounds.max.y;
141 float4 color = is_inside ? input.load_pixel<float4>(texel) : float4(0.0f);
142 output.store_pixel(texel, color);
149 if (this->
context().use_gpu()) {
207 const int2 input_size =
input.domain().size;
221 this->
get_input(
"X").get_single_value_default(0), 0, input_size.x - 1);
223 this->
get_input(
"Y").get_single_value_default(0), 0, input_size.y - 1);
224 const int width =
math::max(1, this->
get_input(
"Width").get_single_value_default(100));
225 const int height =
math::max(1, this->
get_input(
"Height").get_single_value_default(100));
257 "Crops image to a smaller region, either making the cropped area transparent or resizing "
261 ntype.
declare = file_ns::cmp_node_crop_declare;
#define NODE_CLASS_DISTORT
void GPU_shader_bind(blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_2iv(blender::gpu::Shader *sh, const char *name, const int data[2])
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
gpu::Shader * get_shader(const char *info_name, ResultPrecision precision)
NodeOperation(Context &context, DNode 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)
T get_single_value_default(const T &default_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
const Domain & domain() const
void unbind_as_image() const
void bind_as_image(gpu::Shader *shader, const char *image_name, bool read=false) const
bool is_single_value() const
StructureType structure_type
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()
NodeOperation(Context &context, DNode node)
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))
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 cmp_node_crop_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
static void register_node_type_cmp_crop()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeGetCompositorOperationFunction get_compositor_operation
const char * enum_name_legacy
NodeDeclareFunction declare