Viewport: Add theme option for major grid lines

Add a theme option to color the major grid lines in the 3D Viewport.

The default color is the same as grids, just more opaque. The light theme
is also adjusted, as previously the major lines were almost invisible.

Accessibility-wise this also help users that wish to increase contrast.

See PR for screenshots.

Pull Request: https://projects.blender.org/blender/blender/pulls/146861
This commit is contained in:
Pablo Vazquez 2026-02-04 12:53:53 +01:00 • committed by Pablo Vazquez
parent e976e27277
commit d69338bb28
9 changed files with 20 additions and 3 deletions

View file

@ -371,6 +371,7 @@ const bTheme U_theme_default = {
.header_text = RGBA(0xeeeeeeff),
.header_text_hi = RGBA(0xffffffff),
.grid = RGBA(0x54545480),
.grid_major = RGBA(0x545454ff),
.wire = RGBA(0x000000ff),
.wire_edit = RGBA(0x000000ff),
.select = RGBA(0xed5700ff),

View file

@ -470,6 +470,7 @@
<view_3d>
<ThemeView3D
grid="#00000033"
grid_major="#00000066"
clipping_border_3d="#606060ff"
wire="#000000"
wire_edit="#000000"

View file

@ -31,7 +31,7 @@ namespace blender {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 25
#define BLENDER_FILE_SUBVERSION 26
/* 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

@ -423,6 +423,10 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
FROM_DEFAULT_V4_UCHAR(space_preferences.match);
}
if (!USER_VERSION_ATLEAST(501, 26)) {
FROM_DEFAULT_V4_UCHAR(space_view3d.grid_major);
}
/**
* Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a USER_VERSION_ATLEAST check.

View file

@ -364,7 +364,8 @@ void Resources::update_theme_settings(const DRWContext *ctx, const State &state)
/* Emphasize division lines lighter instead of darker, if background is darker than grid. */
const bool is_bg_darker = reduce_add(gb.colors.grid.xyz()) + 0.12f >
reduce_add(gb.colors.background.xyz());
ui::theme::get_color_shade_4fv(TH_GRID, (is_bg_darker) ? 30 : -10, gb.colors.grid_emphasis);
ui::theme::get_color_shade_4fv(
TH_GRID_MAJOR, (is_bg_darker) ? 20 : -10, gb.colors.grid_emphasis);
/* Grid Axis */
ui::theme::get_color_blend_shade_4fv(TH_GRID, TH_AXIS_X, 0.85f, -20, gb.colors.grid_axis_x);

View file

@ -85,6 +85,7 @@ enum ThemeColorID {
TH_HILITE,
TH_GRID,
TH_GRID_MAJOR,
TH_WIRE,
TH_WIRE_INNER,
TH_WIRE_EDIT,

View file

@ -337,6 +337,9 @@ const uchar *get_color_ptr(bTheme *btheme, int spacetype, int colorid)
case TH_GRID:
cp = ts->grid;
break;
case TH_GRID_MAJOR:
cp = ts->grid_major;
break;
case TH_TIME_SCRUB_BACKGROUND:
cp = btheme->regions.scrubbing.back;
break;

View file

@ -316,7 +316,8 @@ typedef struct ThemeSpace {
unsigned char shade2[4];
unsigned char hilite[4];
unsigned char grid[4];
unsigned char grid[4], grid_major[4];
char _pad5[4];
unsigned char view_overlay[4];

View file

@ -2851,6 +2851,11 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Grid", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "grid_major", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Major Grid Lines", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "clipping_border_3d", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Clipping Border", "");