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
This commit is contained in:
Nika Kutsniashvili
2025-09-27 13:25:34 +02:00
committed by Nika Kutsniashvili
parent 65f41c4119
commit 3e51b449be
7 changed files with 25 additions and 2 deletions

View File

@@ -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"

View File

@@ -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

View File

@@ -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.

View File

@@ -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);

View File

@@ -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,\

View File

@@ -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;

View File

@@ -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(