27 .default_value({0.0f, 0.0f})
30 .structure_type(StructureType::Dynamic)
32 "A value that is relative to the image size and needs to be converted to be in pixels");
33 b.add_input<
decl::Float>(
"Value"_ustr,
"Float Value"_ustr)
38 .structure_type(StructureType::Dynamic)
40 "A value that is relative to the image size and needs to be converted to be in pixels");
45 b.add_output<
decl::Float>(
"Value"_ustr,
"Float Value"_ustr)
46 .structure_type(StructureType::Dynamic);
73 const bool is_per_dimension = reference_dimension ==
95 {0,
nullptr, 0,
nullptr,
nullptr},
113 "The value is relative to each of the dimensions of the image independently"},
118 "The value is relative to the X dimension of the image"},
123 "The value is relative to the Y dimension of the image"},
128 "The value is relative to the greater dimension of the image"},
133 "The value is relative to the smaller dimension of the image"},
138 "The value is relative to the diagonal of the image"},
139 {0,
nullptr, 0,
nullptr,
nullptr},
144 "reference_dimension",
145 "Reference Dimension",
146 "Defines the dimension of the image that the relative value is in reference to",
147 reference_dimension_items,
209 const float value_in_pixels = input_value * reference_size.x;
212 output.allocate_single_value();
213 output.set_single_value(value_in_pixels);
218 if (this->
context().use_gpu()) {
256 output.store_pixel(texel, input.load_pixel<float>(texel) * reference_size);
265 const float2 value_in_pixels = input_value * reference_size;
268 output.allocate_single_value();
269 output.set_single_value(value_in_pixels);
274 if (this->
context().use_gpu()) {
312 output.store_pixel(texel, input.load_pixel<float>(texel) * reference_size);
321 const float2 value_in_pixels = input_value * reference_size;
324 output.allocate_single_value();
325 output.set_single_value(value_in_pixels);
330 if (this->
context().use_gpu()) {
368 output.store_pixel(texel, input.load_pixel<float2>(texel) * reference_size);
385 return float2(image_size.x);
387 return float2(image_size.y);
421 ntype.
ui_name =
"Relative To Pixel";
423 "Converts values that are relative to the image size to be in terms of pixels";
#define NODE_CLASS_CONVERTER
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
#define BLI_assert_unreachable()
gpu::Shader * get_shader(const char *info_name, ResultPrecision precision)
Domain realize_transformation(const bool realize_translation=false) const
NodeOperation(Context &context, const bNode &node)
const bNode & node() const
Result & get_result(StringRef identifier)
Context & context() const
Result & get_input(StringRef identifier) const
InputDescriptor & get_input_descriptor(StringRef identifier)
bool is_single_value() const
void unbind_as_texture() const
void bind_as_texture(gpu::Shader *shader, const char *texture_name) const
T get_single_value_default() const
StructureType structure_type
CMPNodeRelativeToPixelReferenceDimension get_reference_dimension()
void execute_vector_gpu()
void execute_float_per_dimension_single()
void execute_float_per_dimension()
void execute_float_per_dimension_gpu()
void execute_float_single()
void execute_vector_cpu()
RelativeToPixelOperation(Context &context, const bNode &node)
CMPNodeRelativeToPixelDataType get_data_type()
void execute_float_per_dimension_cpu()
void execute_vector_single()
float2 compute_reference_size()
void node_register_type(bNodeType &ntype)
void node_set_socket_availability(bNodeTree &ntree, bNodeSocket &sock, bool is_available)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
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 reduce_max(const VecBase< T, Size > &a)
T length(const VecBase< T, Size > &a)
T reduce_min(const VecBase< T, Size > &a)
static void node_declare(NodeDeclarationBuilder &b)
static void node_register()
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
static void node_init(bNodeTree *, bNode *node)
static void node_rna(StructRNA *srna)
static void node_update(bNodeTree *ntree, bNode *node)
static void node_draw_buttons(ui::Layout &layout, bContext *, PointerRNA *ptr)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
CMPNodeRelativeToPixelReferenceDimension
@ CMP_NODE_RELATIVE_TO_PIXEL_REFERENCE_DIMENSION_DIAGONAL
@ CMP_NODE_RELATIVE_TO_PIXEL_REFERENCE_DIMENSION_GREATER
@ CMP_NODE_RELATIVE_TO_PIXEL_REFERENCE_DIMENSION_SMALLER
@ CMP_NODE_RELATIVE_TO_PIXEL_REFERENCE_DIMENSION_X
@ CMP_NODE_RELATIVE_TO_PIXEL_REFERENCE_DIMENSION_PER_DIMENSION
@ CMP_NODE_RELATIVE_TO_PIXEL_REFERENCE_DIMENSION_Y
CMPNodeRelativeToPixelDataType
@ CMP_NODE_RELATIVE_TO_PIXEL_DATA_TYPE_FLOAT
@ CMP_NODE_RELATIVE_TO_PIXEL_DATA_TYPE_VECTOR
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_2fv(gpu::Shader *sh, const char *name, const float data[2])
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)
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
void(*) updatefunc(bNodeTree *ntree, bNode *node)
NodeGetCompositorOperationFunction get_compositor_operation
void(*) initfunc(bNodeTree *ntree, bNode *node)
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)