30 b.add_input<
decl::Color>(
"Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
35 .description(
"The X position of the lower left corner of the crop region");
40 .description(
"The Y position of the lower left corner of the crop region");
45 .description(
"The width of the crop region");
50 .description(
"The height of the crop region");
55 "Sets the areas outside of the crop region to be transparent instead of actually "
56 "cropping the size of the image");
88 if (this->
context().use_gpu()) {
133 bool is_inside = texel.x >= bounds.min.x && texel.y >= bounds.min.y &&
134 texel.x < bounds.max.x && texel.y < bounds.max.y;
136 float4 color = is_inside ? input.load_pixel<float4>(texel) : float4(0.0f);
137 output.store_pixel(texel, color);
144 if (this->
context().use_gpu()) {
202 const int2 input_size =
input.domain().size;
216 this->
get_input(
"X").get_single_value_default(0), 0, input_size.x - 1);
218 this->
get_input(
"Y").get_single_value_default(0), 0, input_size.y - 1);
219 const int width =
math::max(1, this->
get_input(
"Width").get_single_value_default(100));
220 const int height =
math::max(1, this->
get_input(
"Height").get_single_value_default(100));
252 "Crops image to a smaller region, either making the cropped area transparent or resizing "
256 ntype.
declare = file_ns::cmp_node_crop_declare;
#define NODE_CLASS_DISTORT
void GPU_shader_bind(GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_2iv(GPUShader *sh, const char *name, const int data[2])
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
GPUShader * 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(Domain domain, bool from_pool=true)
void unbind_as_texture() const
void bind_as_texture(GPUShader *shader, const char *texture_name) const
const Domain & domain() const
void bind_as_image(GPUShader *shader, const char *image_name, bool read=false) const
void unbind_as_image() const
bool is_single_value() const
bool compositor_expects_single_value() const
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(GPUShader *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