From 3e51b449bec4e208090228d9d1a0aa9aee20baf0 Mon Sep 17 00:00:00 2001 From: Nika Kutsniashvili Date: Sat, 27 Sep 2025 13:25:34 +0200 Subject: [PATCH] UI: Per-camera composition guide colors Currently cameras composition guide colors are defined in theme, and not even by an individual property. They follow 3D Viewport -> View Overlay color, which also defines many other things, such as world origin cursor. By default it's black and it's difficult to change, because then other things stand out. But using default black for composition guides is impossible. This PR, instead, adds new Composition Guide Color property on camera, and uses it in camera view. This not only fixes the issue mentioned above, but also allows different cameras in one scene to have different overlay colors. This is very handy when you have, for example, two cameras, one of which looks at the black corner, and another at the lit-up white one. Using a single black or white color in this case makes the other one more difficult to see. Now, each camera can have its own color. This PR only changes color for Composition Guides, and NOT for Safe Areas and sensor. Reasons are: - It's important to differentiate between different concepts, having everything one color is distracting - Safe areas are per-scene and shared with Sequencer preview. The camera shouldn't dictate color there. I have separate plans about handling safe areas in the future. Images in the PR. Pull Request: https://projects.blender.org/blender/blender/pulls/143788 --- scripts/startup/bl_ui/properties_data_camera.py | 3 +++ source/blender/blenkernel/BKE_blender_version.h | 2 +- source/blender/blenloader/intern/versioning_500.cc | 8 ++++++++ source/blender/editors/space_view3d/view3d_draw.cc | 5 ++++- source/blender/makesdna/DNA_camera_defaults.h | 1 + source/blender/makesdna/DNA_camera_types.h | 3 +++ source/blender/makesrna/intern/rna_camera.cc | 5 +++++ 7 files changed, 25 insertions(+), 2 deletions(-) diff --git a/scripts/startup/bl_ui/properties_data_camera.py b/scripts/startup/bl_ui/properties_data_camera.py index 4fd5f01107d..04273aaeb1c 100644 --- a/scripts/startup/bl_ui/properties_data_camera.py +++ b/scripts/startup/bl_ui/properties_data_camera.py @@ -492,6 +492,9 @@ class DATA_PT_camera_display_composition_guides(CameraButtonsPanel, Panel): col.prop(cam, "show_composition_harmony_tri_a", text="Triangle A") col.prop(cam, "show_composition_harmony_tri_b", text="Triangle B") + col = layout.column() + col.prop(cam, "composition_guide_color", text="Color") + class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel): bl_label = "Safe Areas" diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 663c76d7aaf..89ad53389a0 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -27,7 +27,7 @@ /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 94 +#define BLENDER_FILE_SUBVERSION 95 /* 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 diff --git a/source/blender/blenloader/intern/versioning_500.cc b/source/blender/blenloader/intern/versioning_500.cc index b599f4a74e1..cc1776a135d 100644 --- a/source/blender/blenloader/intern/versioning_500.cc +++ b/source/blender/blenloader/intern/versioning_500.cc @@ -17,6 +17,7 @@ #include "DNA_ID.h" #include "DNA_brush_types.h" +#include "DNA_camera_types.h" #include "DNA_curves_types.h" #include "DNA_genfile.h" #include "DNA_grease_pencil_types.h" @@ -3669,6 +3670,13 @@ void blo_do_versions_500(FileData *fd, Library * /*lib*/, Main *bmain) do_version_adaptive_subdivision(bmain); } + if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 95)) { + LISTBASE_FOREACH (Camera *, camera, &bmain->cameras) { + float default_col[4] = {0.5f, 0.5f, 0.5f, 1.0f}; + copy_v4_v4(camera->composition_guide_color, default_col); + } + } + /** * Always bump subversion in BKE_blender_version.h when adding versioning * code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check. diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index e1e62e011d6..5b086b9b0c8 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -663,7 +663,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region, /* safety border */ if (ca && (v3d->flag2 & V3D_SHOW_CAMERA_GUIDES)) { GPU_blend(GPU_BLEND_ALPHA); - immUniformThemeColorAlpha(TH_VIEW_OVERLAY, 0.75f); + immUniformColor4fv(ca->composition_guide_color); if (ca->dtx & CAM_DTX_CENTER) { float x3, y3; @@ -725,6 +725,9 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region, margins_rect.ymin = y1; margins_rect.ymax = y2; + /* draw */ + immUniformThemeColorAlpha(TH_VIEW_OVERLAY, 0.75f); + UI_draw_safe_areas( shdr_pos, &margins_rect, scene->safe_areas.title, scene->safe_areas.action); diff --git a/source/blender/makesdna/DNA_camera_defaults.h b/source/blender/makesdna/DNA_camera_defaults.h index 7a6653f93a4..87cdd45c32c 100644 --- a/source/blender/makesdna/DNA_camera_defaults.h +++ b/source/blender/makesdna/DNA_camera_defaults.h @@ -40,6 +40,7 @@ .ortho_scale = 6.0, \ .flag = CAM_SHOWPASSEPARTOUT, \ .passepartalpha = 0.5f, \ + .composition_guide_color = {0.5f, 0.5f, 0.5f, 1.0f}, \ \ .panorama_type = CAM_PANORAMA_FISHEYE_EQUISOLID,\ .fisheye_fov = M_PI,\ diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index 819f87d26a3..2e80b467bc5 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -134,6 +134,9 @@ typedef struct Camera { /* Stereo settings */ struct CameraStereoSettings stereo; + /* Compositional guide overlay color */ + float composition_guide_color[4]; + /** Runtime data (keep last). */ Camera_Runtime runtime; } Camera; diff --git a/source/blender/makesrna/intern/rna_camera.cc b/source/blender/makesrna/intern/rna_camera.cc index c112c5fff46..72067667a26 100644 --- a/source/blender/makesrna/intern/rna_camera.cc +++ b/source/blender/makesrna/intern/rna_camera.cc @@ -899,6 +899,11 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Lens Unit", "Unit to edit lens in for the user interface"); /* dtx */ + prop = RNA_def_property(srna, "composition_guide_color", PROP_FLOAT, PROP_COLOR); + RNA_def_property_ui_text( + prop, "Composition Guide Color", "Color and alpha for compositional guide overlays"); + RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, nullptr); + prop = RNA_def_property(srna, "show_composition_center", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "dtx", CAM_DTX_CENTER); RNA_def_property_ui_text(