62 b.use_custom_socket_order();
63 b.allow_any_socket_order();
65 b.add_default_layout();
69 if (!node_tree || !
node) {
100 .custom_draw(socket_items::ui::draw_extend_socket_fn<FileOutputItemsAccessor>());
107 data->save_as_render =
true;
108 data->use_file_extension =
true;
130 MEM_SAFE_DELETE(
data.file_name);
135 bNode *destination_node,
136 const bNode *source_node)
143 destination_node->
storage = destination_storage;
166 const int frame_number,
171 const bool is_animation_render,
176 const std::string full_file_name = file_name + file_name_suffix;
188 if (!is_animation_render) {
198 bool(node_storage(
node).use_file_extension),
217 col.
prop(node_or_item_pointer,
222 const bool save_as_render =
RNA_boolean_get(node_or_item_pointer,
"save_as_render");
225 if (!save_as_render) {
265 if (path_errors.is_empty()) {
266 layout.
label(image_path, ICON_FILE_IMAGE);
284 const std::string file_name =
storage.file_name ?
storage.file_name :
"";
295 layout, directory, file_name, file_name_suffix, view.
name, format,
main, scene,
node);
300 layout, directory, file_name, file_name_suffix,
"", format,
main, scene,
node);
308 const bool is_multi_layer)
312 layout.
prop(item_pointer,
"socket_type",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
314 layout.
prop(item_pointer,
"vector_socket_dimensions",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
317 if (is_multi_layer) {
323 const bool override_node_format =
RNA_boolean_get(item_pointer,
"override_node_format");
327 PointerRNA *format_pointer = override_node_format ? &item_format_pointer : &node_format_pointer;
329 if (override_node_format) {
343 const bool is_multi_layer =
RNA_enum_get(&format_pointer,
"file_format") ==
347 format_layout(panel, context, &format_pointer, node_pointer);
350 const char *panel_name = is_multi_layer ?
IFACE_(
"Layers") :
IFACE_(
"Images");
351 if (
ui::Layout *panel = layout.
panel(context,
"file_output_items",
false, panel_name)) {
354 socket_items::ui::draw_items_list_with_operators<FileOutputItemsAccessor>(
355 context, panel, tree,
node);
356 socket_items::ui::draw_active_item_props<FileOutputItemsAccessor>(
358 item_layout(*panel, context, node_pointer, item_pointer, is_multi_layer);
369 if (is_multi_layer) {
404 row.
text =
RPT_(
"Node Unsupported");
405 row.
tooltip =
TIP_(
"The File Output node is only supported for scene compositing");
406 row.
icon = ICON_STATUS_ERROR;
407 parameters.
rows.append(std::move(row));
422 bNode &
node = params.add_node(
"CompositorNodeOutputFile"_ustr);
436 params.update_and_connect_available_socket(
node,
UString(params.socket.name));
468 if (
result.is_single_value()) {
478 node_storage(this->
node()).format;
481 node_storage(this->
node()).save_as_render;
484 &this->
context().get_render_data());
492 format, item.
name,
"", image_path);
493 if (!path_errors.is_empty()) {
499 image_path, format, size, save_as_render);
513 const char *layer_name)
523 format, layer_name, path_view, image_path);
524 if (!path_errors.is_empty()) {
530 image_path, format, size,
true);
549 if (size ==
int2(1)) {
560 const char *write_view = store_views_in_single_file ?
"" : view;
562 format,
"", write_view, image_path);
563 if (!path_errors.is_empty()) {
568 image_path, format, size,
true);
572 const char *pass_view = store_views_in_single_file ? view :
"";
590 const char *pass_name,
591 const char *view_name)
594 if (
result.is_single_value()) {
601 single_value.
get(),
data.cpu_data_for_write().data(), pixel_count);
603 else if (this->
context().use_gpu()) {
605 data.share_data(result_cpu);
617 if (
result.meta_data.is_cryptomatte_layer()) {
618 file_output.
add_pass(pass_name, view_name,
"rgba",
data);
621 file_output.
add_pass(pass_name, view_name,
"RGBA",
data);
625 file_output.
add_pass(pass_name, view_name,
"XYZ",
data);
628 file_output.
add_pass(pass_name, view_name,
"XYZW",
data);
665 if (this->
context().use_gpu()) {
667 data.share_data(result_cpu);
719 if (
result.meta_data.is_cryptomatte_layer()) {
722 cryptomatte_layer_name);
725 if (!
result.meta_data.cryptomatte.manifest.empty()) {
728 result.meta_data.cryptomatte.manifest);
731 if (!
result.meta_data.cryptomatte.hash.empty()) {
734 result.meta_data.cryptomatte.hash);
737 if (!
result.meta_data.cryptomatte.conversion.empty()) {
740 result.meta_data.cryptomatte.conversion);
743 for (
const auto &item :
result.meta_data.fields.items()) {
749 const char *file_name_suffix,
758 this->
context().get_frame_number(),
766 if (!path_errors.is_empty()) {
768 nullptr,
RPT_ERROR,
"Invalid path template in File Output node. Skipping writing file.");
781 const char *file_name = node_storage(this->
node()).file_name;
782 return file_name ? file_name :
"";
787 return node_storage(this->
node()).directory;
820 if (!this->
context().render_context()) {
#define NODE_CLASS_OUTPUT
#define NODE_STORAGE_FUNCS(StorageT)
#define CMP_NODE_OUTPUT_FILE
Read Blender memory allocation and freeing.
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define BLI_assert_unreachable()
void fill_assign_n(const void *value, void *dst, int64_t n) const
const CPPType * type() const
constexpr IndexRange()=default
constexpr const char * c_str() const
constexpr const char * data() const
Result create_result(ResultType type, ResultPrecision precision)
virtual StringRef get_view_name() const
virtual const RenderData & get_render_data() const
virtual RenderContext * render_context() const
void add_view(const char *view_name)
void add_pass(const char *pass_name, const char *view_name, const char *channels, const Result &data)
void add_meta_data(std::string key, std::string value)
NodeOperation(Context &context, const bNode &node)
const bNode & node() const
Context & context() const
Result & get_input(StringRef identifier) const
virtual Domain compute_domain()
FileOutput & get_file_output(std::string path, ImageFormatData format, int2 size, bool save_as_render)
BaseSocketDeclarationBuilder & compositor_realization_mode(CompositorInputRealizationMode value)
BaseSocketDeclarationBuilder & structure_type(StructureType structure_type)
BaseSocketDeclarationBuilder & socket_name_ptr(PointerRNA ptr, StringRef property_name)
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
const bNodeTree & node_tree() const
const bNodeSocket & other_socket() const
NodeOperation(Context &context, const bNode &node)
bool is_animation_render()
void execute_multi_layer()
Domain compute_domain() override
void execute_single_layer_multi_view_exr(const Result &result, const ImageFormatData &format, const char *layer_name)
StringRefNull get_directory()
Vector< bke::path_templates::Error > get_image_path(const ImageFormatData &format, const char *file_name_suffix, const char *view, char *r_image_path)
StringRefNull get_file_name()
void add_pass_for_result(FileOutput &file_output, const Result &result, const char *pass_name, const char *view_name)
void execute_single_layer()
void add_meta_data_for_result(FileOutput &file_output, const Result &result, const char *name)
void add_view_for_result(FileOutput &file_output, const Result &result, const char *view_name)
bool is_multi_view_scene()
#define storage(slot, qualifiers)
StringRef BKE_cryptomatte_extract_layer_name(StringRef render_pass_name)
std::string BKE_cryptomatte_meta_data_key(StringRef layer_name, StringRefNull key_name)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
static void node_draw_buttons_extended(ui::Layout &layout, bContext *context, PointerRNA *node_pointer)
static void node_blend_write(const bNodeTree &, const bNode &node, BlendWriter &writer)
static void node_init_api(const bContext *C, PointerRNA *node_ptr)
static void output_path_layout(ui::Layout &layout, const StringRefNull directory, const StringRefNull file_name, const StringRefNull file_name_suffix, const char *view, const ImageFormatData &format, const Main &bmain, const Scene &scene, const bNode &node)
static bool node_insert_link(bke::NodeInsertLinkParams ¶ms)
static void node_register()
static void node_draw_buttons(ui::Layout &layout, bContext *, PointerRNA *node_pointer)
static void node_extra_info(NodeExtraInfoParams ¶meters)
static void node_declare(NodeDeclarationBuilder &b)
static void format_layout(ui::Layout *layout, bContext *context, PointerRNA *format_pointer, PointerRNA *node_or_item_pointer)
static Vector< bke::path_templates::Error > compute_image_path(const StringRefNull directory, const StringRefNull file_name, const StringRefNull file_name_suffix, const char *view, const int frame_number, const ImageFormatData &format, const Main &bmain, const Scene &scene, const bNode &node, const bool is_animation_render, char *r_image_path)
static void node_blend_read(bNodeTree &, bNode &node, BlendDataReader &reader)
static void node_init(bNodeTree *node_tree, bNode *node)
static void node_copy_storage(bNodeTree *, bNode *destination_node, const bNode *source_node)
static void item_layout(ui::Layout &layout, bContext *context, PointerRNA *node_pointer, PointerRNA *item_pointer, const bool is_multi_layer)
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static void node_free_storage(bNode *node)
static void node_register_operators()
static void output_paths_layout(ui::Layout &layout, bContext *context, const StringRefNull file_name_suffix, const bNode &node, const ImageFormatData &format)
void make_common_operators()
void blend_write(BlendWriter *writer, const bNode &node)
void destruct_array(bNode &node)
void blend_read_data(BlendDataReader *reader, bNode &node)
void copy_array(const bNode &src_node, bNode &dst_node)
Accessor::ItemT * add_item_with_socket_type_and_name(bNodeTree &ntree, bNode &node, const eNodeSocketDatatype socket_type, const char *name, std::optional< int > dimensions=std::nullopt)
bool try_add_item_via_any_extend_socket(bNodeTree &ntree, bNode &extend_node, bNode &storage_node, bNodeLink &link, const std::optional< StringRef > socket_identifier=std::nullopt, typename Accessor::ItemT **r_new_item=nullptr)
CompositorInputRealizationMode
@ ITEM_R_SPLIT_EMPTY_NAME
bool BKE_scene_multiview_is_render_view_active(const RenderData *rd, const SceneRenderView *srv)
char * STRNCPY(char(&dst)[N], const char *src)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void uiTemplateImageFormatViews(ui::Layout *layout, PointerRNA *imfptr, PointerRNA *ptr)
void BKE_image_format_media_type_set(ImageFormatData *format, ID *owner_id, const MediaType media_type)
void BKE_add_template_variables_general(bke::path_templates::VariableMap &variables, const ID *path_owner_id, const bke::BlenderProject *project)
bool BLI_path_make_safe(char *path) ATTR_NONNULL(1)
@ MEDIA_TYPE_MULTI_LAYER_IMAGE
void BKE_image_format_blend_write(BlendWriter *writer, ImageFormatData *imf)
bool BLI_path_frame(char *path, size_t path_maxncpy, int frame, int digits) ATTR_NONNULL(1)
size_t BLI_path_append(char *__restrict dst, size_t dst_maxncpy, const char *__restrict file) ATTR_NONNULL(1
const char * BKE_scene_multiview_view_suffix_get(const RenderData *rd, const char *viewname)
const char * BKE_main_blendfile_path_from_global()
Vector< bke::path_templates::Error > BKE_image_path_from_imformat(char *filepath, const char *base, const char *relbase, const bke::path_templates::VariableMap *template_variables, int frame, const ImageFormatData *im_format, bool use_ext, bool use_frames, const char *suffix)
auto BKE_blender_project_read_callback(const Main *bmain, Fn lambda)
int BKE_scene_multiview_num_views_get(const RenderData *rd)
std::string BKE_path_template_error_to_string(const bke::path_templates::Error &error, StringRef path)
void BKE_add_template_variables_for_render_path(bke::path_templates::VariableMap &variables, const Scene &scene)
void BKE_add_template_variables_for_node(bke::path_templates::VariableMap &variables, const bNode &owning_node)
@ R_IMF_IMTYPE_MULTILAYER
void BKE_report(ReportList *reports, eReportType type, const char *message)
BMesh const char void * data
void BKE_image_format_blend_read_data(BlendDataReader *reader, ImageFormatData *imf)
SpaceNode * CTX_wm_space_node(const bContext *C)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void uiTemplateImageSettings(ui::Layout *layout, bContext *C, PointerRNA *imfptr, bool color_management, const char *panel_idname=nullptr)
void BKE_image_format_init(ImageFormatData *imf)
void BKE_image_format_free(ImageFormatData *imf)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
Main * CTX_data_main(const bContext *C)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Scene * CTX_data_scene(const bContext *C)
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
void BKE_image_format_update_color_space_for_type(ImageFormatData *format)
void BKE_image_format_copy(ImageFormatData *imf_dst, const ImageFormatData *imf_src)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
void cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void write_string(const char *data)
char override_node_format
char vector_socket_dimensions
eNodeSocketDatatype socket_type
ListBaseT< SceneRenderView > views
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
NodeBlendWriteFunction blend_write_storage_content
void(*) register_operators()
std::string ui_description
NodeBlendDataReadFunction blend_data_read_storage_content
void(*) initfunc_api(const bContext *C, PointerRNA *ptr)
NodeGetCompositorOperationFunction get_compositor_operation
NodeExtraInfoFunction get_extra_info
void(*) draw_buttons_ex(ui::Layout &, bContext *C, PointerRNA *ptr)
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
bool(*) insert_link(NodeInsertLinkParams ¶ms)
static std::string validate_name(const StringRef name)
static std::string socket_identifier_for_item(const NodeCompositorFileOutputItem &item)
static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int)
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
NodeCompositorFileOutputItem ItemT
static StructRNA ** item_srna
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
void label(StringRef name, int icon)
PanelLayout panel(const bContext *C, StringRef idname, bool default_closed)
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)
Layout & column(bool align)