Compositor: remove "Use Nodes"

Part of simplifying the compositor workflow:
https://projects.blender.org/blender/blender/issues/134214

The option "Use Nodes" is removed from the UI and marked deprecated.
It will get fully removed in 6.0.

"Use Nodes" is effectively replaced by the existing "Compositing"
option in the post-processing panel

Pull Request: https://projects.blender.org/blender/blender/pulls/138560
This commit is contained in:
Habib Gahbiche
2025-06-18 18:39:02 +02:00
parent 83a9cda08f
commit d88d4cc8ce
14 changed files with 58 additions and 39 deletions

View File

@@ -147,9 +147,6 @@ class NODE_HT_header(Header):
NODE_MT_editor_menus.draw_collapsible(context, layout) NODE_MT_editor_menus.draw_collapsible(context, layout)
if snode_id:
layout.prop(snode_id, "use_nodes")
layout.separator_spacer() layout.separator_spacer()
row = layout.row() row = layout.row()
row.enabled = not snode.pin row.enabled = not snode.pin

View File

@@ -27,7 +27,7 @@
/* Blender file format version. */ /* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION #define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 16 #define BLENDER_FILE_SUBVERSION 17
/* Minimum Blender version that supports reading file written with the current /* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to * version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@@ -1009,6 +1009,12 @@ static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_addres
sce->nodetree = reinterpret_cast<bNodeTree *>(MEM_mallocN(1, "dummy pointer")); sce->nodetree = reinterpret_cast<bNodeTree *>(MEM_mallocN(1, "dummy pointer"));
} }
/* Todo(#140111): Forward compatibility support will be removed in 6.0. Remove mapping between
* `scene->use_nodes` and `scene->r.scemode`. */
if (sce->compositing_node_group && sce->r.scemode & R_DOCOMP) {
sce->use_nodes = true;
}
/* write LibData */ /* write LibData */
BLO_write_id_struct(writer, Scene, id_address, &sce->id); BLO_write_id_struct(writer, Scene, id_address, &sce->id);
BKE_id_blend_write(writer, &sce->id); BKE_id_blend_write(writer, &sce->id);

View File

@@ -330,6 +330,21 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
} }
} }
/* "Use Nodes" was removed. */
static void do_version_scene_remove_use_nodes(Scene *scene)
{
if (scene->nodetree == nullptr && scene->compositing_node_group == nullptr) {
/* scene->use_nodes is set to false by default. Files saved without compositing node trees
* should not disable compositing. */
return;
}
else if (scene->use_nodes == false && scene->r.scemode & R_DOCOMP) {
/* A compositing node tree exists but users explicitly disabled compositing. */
scene->r.scemode &= ~R_DOCOMP;
}
/* Ignore use_nodes otherwise. */
}
void do_versions_after_linking_500(FileData * /*fd*/, Main * /*bmain*/) void do_versions_after_linking_500(FileData * /*fd*/, Main * /*bmain*/)
{ {
/** /**
@@ -451,6 +466,12 @@ void blo_do_versions_500(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
FOREACH_NODETREE_END; FOREACH_NODETREE_END;
} }
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 17)) {
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
do_version_scene_remove_use_nodes(scene);
}
}
/** /**
* Always bump subversion in BKE_blender_version.h when adding versioning * Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check. * code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.

View File

@@ -1973,10 +1973,6 @@ bool DRWContext::is_viewport_compositor_enabled() const
return false; return false;
} }
if (!this->scene->use_nodes) {
return false;
}
if (!this->scene->compositing_node_group) { if (!this->scene->compositing_node_group) {
return false; return false;
} }

View File

@@ -251,7 +251,7 @@ static void texture_changed(Main *bmain, Tex *tex)
BKE_paint_invalidate_overlay_tex(scene, view_layer, tex); BKE_paint_invalidate_overlay_tex(scene, view_layer, tex);
} }
/* find compositing nodes */ /* find compositing nodes */
if (scene->use_nodes && scene->compositing_node_group) { if (scene->compositing_node_group) {
for (bNode *node : scene->compositing_node_group->all_nodes()) { for (bNode *node : scene->compositing_node_group->all_nodes()) {
if (node->id == &tex->id) { if (node->id == &tex->id) {
blender::ed::space_node::tag_update_id(&scene->id); blender::ed::space_node::tag_update_id(&scene->id);

View File

@@ -5239,9 +5239,6 @@ static void snode_setup_v2d(SpaceNode &snode, ARegion &region, const float2 &cen
static bool compositor_is_in_use(const bContext &context) static bool compositor_is_in_use(const bContext &context)
{ {
const Scene *scene = CTX_data_scene(&context); const Scene *scene = CTX_data_scene(&context);
if (!scene->use_nodes) {
return false;
}
if (!scene->compositing_node_group) { if (!scene->compositing_node_group) {
return false; return false;

View File

@@ -297,10 +297,6 @@ static void compo_startjob(void *cjv, wmJobWorkerStatus *worker_status)
bNodeTree *ntree = cj->localtree; bNodeTree *ntree = cj->localtree;
Scene *scene = DEG_get_evaluated_scene(cj->compositor_depsgraph); Scene *scene = DEG_get_evaluated_scene(cj->compositor_depsgraph);
if (scene->use_nodes == false) {
return;
}
cj->stop = &worker_status->stop; cj->stop = &worker_status->stop;
cj->do_update = &worker_status->do_update; cj->do_update = &worker_status->do_update;
cj->progress = &worker_status->progress; cj->progress = &worker_status->progress;

View File

@@ -1241,11 +1241,9 @@ static void node_area_refresh(const bContext *C, ScrArea *area)
if (snode->nodetree) { if (snode->nodetree) {
if (snode->nodetree->type == NTREE_COMPOSIT) { if (snode->nodetree->type == NTREE_COMPOSIT) {
Scene *scene = (Scene *)snode->id; Scene *scene = (Scene *)snode->id;
if (scene->use_nodes) { if (snode->runtime->recalc_regular_compositing) {
if (snode->runtime->recalc_regular_compositing) { snode->runtime->recalc_regular_compositing = false;
snode->runtime->recalc_regular_compositing = false; ED_node_composite_job(C, snode->nodetree, scene);
ED_node_composite_job(C, snode->nodetree, scene);
}
} }
} }
} }

View File

@@ -2085,7 +2085,7 @@ typedef struct Scene {
/** Various settings. */ /** Various settings. */
short flag; short flag;
char use_nodes; char use_nodes DNA_DEPRECATED;
char _pad3[1]; char _pad3[1];
struct bNodeTree *nodetree DNA_DEPRECATED; struct bNodeTree *nodetree DNA_DEPRECATED;

View File

@@ -1997,10 +1997,24 @@ static std::optional<std::string> rna_SceneRenderView_path(const PointerRNA *ptr
return fmt::format("render.views[\"{}\"]", srv_name_esc); return fmt::format("render.views[\"{}\"]", srv_name_esc);
} }
static bool rna_Scene_use_nodes_get(PointerRNA *ptr)
{
Scene *scene = reinterpret_cast<Scene *>(ptr->data);
return scene->r.scemode & R_DOCOMP;
}
static void rna_Scene_use_nodes_set(PointerRNA *ptr, const bool use_nodes)
{
Scene *scene = reinterpret_cast<Scene *>(ptr->data);
SET_FLAG_FROM_TEST(scene->r.scemode, use_nodes, R_DOCOMP);
}
/* Todo(#140111): Remove in 6.0. In Python API, this function is used to create a compositing node
* tree if none exists. scene.use_nodes will be replaced by the existing scene.use_compositing. */
static void rna_Scene_use_nodes_update(bContext *C, PointerRNA *ptr) static void rna_Scene_use_nodes_update(bContext *C, PointerRNA *ptr)
{ {
Scene *scene = (Scene *)ptr->data; Scene *scene = (Scene *)ptr->data;
if (scene->use_nodes && scene->compositing_node_group == nullptr) { if (scene->r.scemode & R_DOCOMP && scene->compositing_node_group == nullptr) {
ED_node_composit_default(C, scene); ED_node_composit_default(C, scene);
} }
DEG_relations_tag_update(CTX_data_main(C)); DEG_relations_tag_update(CTX_data_main(C));
@@ -7332,7 +7346,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, RNA_def_property_ui_text(prop,
"Compositing", "Compositing",
"Process the render result through the compositing pipeline, " "Process the render result through the compositing pipeline, "
"if compositing nodes are enabled"); "if a compositing node group is assigned to the scene");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
prop = RNA_def_property(srna, "use_sequencer", PROP_BOOLEAN, PROP_NONE); prop = RNA_def_property(srna, "use_sequencer", PROP_BOOLEAN, PROP_NONE);
@@ -9051,7 +9065,9 @@ void RNA_def_scene(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "use_nodes", 1); RNA_def_property_boolean_sdna(prop, nullptr, "use_nodes", 1);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_ui_text(prop, "Use Nodes", "Enable the compositing node tree"); RNA_def_property_ui_text(
prop, "Use Nodes", "Enable the compositing node tree. (Deprecated: use use_compositing)");
RNA_def_property_boolean_funcs(prop, "rna_Scene_use_nodes_get", "rna_Scene_use_nodes_set");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_use_nodes_update"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_use_nodes_update");
/* Sequencer */ /* Sequencer */

View File

@@ -856,7 +856,7 @@ static bool possibly_using_gpu_compositor(const Render *re)
} }
const Scene *scene = re->pipeline_scene_eval; const Scene *scene = re->pipeline_scene_eval;
return (scene->compositing_node_group && scene->use_nodes && (scene->r.scemode & R_DOCOMP)); return (scene->compositing_node_group && (scene->r.scemode & R_DOCOMP));
} }
static void engine_render_view_layer(Render *re, static void engine_render_view_layer(Render *re,

View File

@@ -715,7 +715,7 @@ void RE_FreeUnusedGPUResources()
/* Detect if scene is using GPU compositing, and if either a node editor is /* Detect if scene is using GPU compositing, and if either a node editor is
* showing the nodes, or an image editor is showing the render result or viewer. */ * showing the nodes, or an image editor is showing the render result or viewer. */
if (!(scene->use_nodes && scene->compositing_node_group && if (!(scene->compositing_node_group &&
scene->r.compositor_device == SCE_COMPOSITOR_DEVICE_GPU)) scene->r.compositor_device == SCE_COMPOSITOR_DEVICE_GPU))
{ {
continue; continue;
@@ -1222,9 +1222,6 @@ static bool compositor_needs_render(Scene *scene)
if (ntree == nullptr) { if (ntree == nullptr) {
return true; return true;
} }
if (scene->use_nodes == false) {
return true;
}
if ((scene->r.scemode & R_DOCOMP) == 0) { if ((scene->r.scemode & R_DOCOMP) == 0) {
return true; return true;
} }
@@ -1360,7 +1357,7 @@ static void do_render_compositor(Render *re)
} }
if (!re->test_break()) { if (!re->test_break()) {
if (ntree && re->scene->use_nodes && re->r.scemode & R_DOCOMP) { if (ntree && re->r.scemode & R_DOCOMP) {
/* checks if there are render-result nodes that need scene */ /* checks if there are render-result nodes that need scene */
if ((re->r.scemode & R_SINGLE_LAYER) == 0) { if ((re->r.scemode & R_SINGLE_LAYER) == 0) {
do_render_compositor_scenes(re); do_render_compositor_scenes(re);
@@ -1678,7 +1675,7 @@ static bool check_valid_compositing_camera(Scene *scene,
Object *camera_override, Object *camera_override,
ReportList *reports) ReportList *reports)
{ {
if (scene->r.scemode & R_DOCOMP && scene->use_nodes) { if (scene->r.scemode & R_DOCOMP && scene->compositing_node_group) {
for (bNode *node : scene->compositing_node_group->all_nodes()) { for (bNode *node : scene->compositing_node_group->all_nodes()) {
if (node->type_legacy == CMP_NODE_R_LAYERS && !node->is_muted()) { if (node->type_legacy == CMP_NODE_R_LAYERS && !node->is_muted()) {
Scene *sce = node->id ? (Scene *)node->id : scene; Scene *sce = node->id ? (Scene *)node->id : scene;
@@ -1859,13 +1856,8 @@ bool RE_is_rendering_allowed(Scene *scene,
return false; return false;
} }
} }
else if ((scemode & R_DOCOMP) && scene->use_nodes) { else if (scemode & R_DOCOMP && scene->compositing_node_group) {
/* Compositor */ /* Compositor */
if (!scene->compositing_node_group) {
BKE_report(reports, RPT_ERROR, "No node tree in scene");
return false;
}
if (!check_compositor_output(scene)) { if (!check_compositor_output(scene)) {
BKE_report(reports, RPT_ERROR, "No render output node in scene"); BKE_report(reports, RPT_ERROR, "No render output node in scene");
return false; return false;

View File

@@ -1416,7 +1416,7 @@ static ImBuf *seq_render_scene_strip(const RenderData *context,
#if 0 /* UNUSED */ #if 0 /* UNUSED */
have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first; have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first;
#endif #endif
have_comp = (scene->r.scemode & R_DOCOMP) && scene->use_nodes && scene->compositing_node_group; have_comp = (scene->r.scemode & R_DOCOMP) && scene->compositing_node_group;
/* Get view layer for the strip. */ /* Get view layer for the strip. */
ViewLayer *view_layer = BKE_view_layer_default_render(scene); ViewLayer *view_layer = BKE_view_layer_default_render(scene);