Overlay: Split theme colors and sizes into different structs

Centralize processing of each and allow
more semanticaly correct references.
This commit is contained in:
Clément Foucault
2025-04-26 01:52:39 +02:00
committed by Clément Foucault
parent 17d8650d2d
commit 27a8c00157
14 changed files with 445 additions and 426 deletions

View File

@@ -663,32 +663,32 @@ static void drw_shgroup_bone_relationship_lines(const Armatures::DrawContext *ct
const float start[3],
const float end[3])
{
const GlobalsUboStorage &theme = ctx->res->theme_settings;
drw_shgroup_bone_relationship_lines_ex(ctx, start, end, theme.color_wire);
const GlobalsUboStorage &theme = ctx->res->theme;
drw_shgroup_bone_relationship_lines_ex(ctx, start, end, theme.colors.wire);
}
static void drw_shgroup_bone_ik_lines(const Armatures::DrawContext *ctx,
const float start[3],
const float end[3])
{
const GlobalsUboStorage &theme = ctx->res->theme_settings;
drw_shgroup_bone_relationship_lines_ex(ctx, start, end, theme.color_bone_ik_line);
const GlobalsUboStorage &theme = ctx->res->theme;
drw_shgroup_bone_relationship_lines_ex(ctx, start, end, theme.colors.bone_ik_line);
}
static void drw_shgroup_bone_ik_no_target_lines(const Armatures::DrawContext *ctx,
const float start[3],
const float end[3])
{
const GlobalsUboStorage &theme = ctx->res->theme_settings;
drw_shgroup_bone_relationship_lines_ex(ctx, start, end, theme.color_bone_ik_line_no_target);
const GlobalsUboStorage &theme = ctx->res->theme;
drw_shgroup_bone_relationship_lines_ex(ctx, start, end, theme.colors.bone_ik_line_no_target);
}
static void drw_shgroup_bone_ik_spline_lines(const Armatures::DrawContext *ctx,
const float start[3],
const float end[3])
{
const GlobalsUboStorage &theme = ctx->res->theme_settings;
drw_shgroup_bone_relationship_lines_ex(ctx, start, end, theme.color_bone_ik_line_spline);
const GlobalsUboStorage &theme = ctx->res->theme;
drw_shgroup_bone_relationship_lines_ex(ctx, start, end, theme.colors.bone_ik_line_spline);
}
/** \} */
@@ -778,16 +778,16 @@ static void get_pchan_color_wire(const GlobalsUboStorage &theme,
}
else {
if (draw_active && draw_selected) {
wire_color = is_edit ? theme.color_bone_active : theme.color_bone_pose_active;
wire_color = is_edit ? theme.colors.bone_active : theme.colors.bone_pose_active;
}
else if (draw_active) {
wire_color = is_edit ? theme.color_bone_active_unsel : theme.color_bone_pose_active_unsel;
wire_color = is_edit ? theme.colors.bone_active_unsel : theme.colors.bone_pose_active_unsel;
}
else if (draw_selected) {
wire_color = is_edit ? theme.color_bone_select : theme.color_bone_pose;
wire_color = is_edit ? theme.colors.bone_select : theme.colors.bone_pose;
}
else {
wire_color = is_edit ? theme.color_wire_edit : theme.color_wire;
wire_color = is_edit ? theme.colors.wire_edit : theme.colors.wire;
}
copy_v4_v4(r_color, wire_color);
}
@@ -802,7 +802,7 @@ static void get_pchan_color_solid(const GlobalsUboStorage &theme,
use_bone_color(r_color, bcolor->solid, 0);
}
else {
copy_v4_v4(r_color, theme.color_bone_solid);
copy_v4_v4(r_color, theme.colors.bone_solid);
}
}
@@ -828,16 +828,16 @@ static void get_pchan_color_constraint(const GlobalsUboStorage &theme,
float4 constraint_color;
if (constflag & PCHAN_HAS_NO_TARGET) {
constraint_color = theme.color_bone_pose_no_target;
constraint_color = theme.colors.bone_pose_no_target;
}
else if (constflag & PCHAN_HAS_IK) {
constraint_color = theme.color_bone_pose_ik;
constraint_color = theme.colors.bone_pose_ik;
}
else if (constflag & PCHAN_HAS_SPLINEIK) {
constraint_color = theme.color_bone_pose_spline_ik;
constraint_color = theme.colors.bone_pose_spline_ik;
}
else if (constflag & PCHAN_HAS_CONST) {
constraint_color = theme.color_bone_pose_constraint;
constraint_color = theme.colors.bone_pose_constraint;
}
interp_v4_v4v4(r_color, solid_color, constraint_color, 0.5f);
}
@@ -850,7 +850,7 @@ static void get_pchan_color_constraint(const GlobalsUboStorage &theme,
static void bone_locked_color_shade(const GlobalsUboStorage &theme, float color[4])
{
const float *locked_color = theme.color_bone_locked;
const float *locked_color = theme.colors.bone_locked;
interp_v3_v3v3(color, color, locked_color, locked_color[3]);
}
@@ -858,9 +858,9 @@ static void bone_locked_color_shade(const GlobalsUboStorage &theme, float color[
static const float *get_bone_solid_color(const Armatures::DrawContext *ctx,
const eBone_Flag boneflag)
{
const GlobalsUboStorage &theme = ctx->res->theme_settings;
const GlobalsUboStorage &theme = ctx->res->theme;
if (ctx->const_color) {
return theme.color_bone_solid;
return theme.colors.bone_solid;
}
static float disp_color[4];
@@ -877,9 +877,9 @@ static const float *get_bone_solid_with_consts_color(const Armatures::DrawContex
const UnifiedBonePtr bone,
const eBone_Flag boneflag)
{
const GlobalsUboStorage &theme = ctx->res->theme_settings;
const GlobalsUboStorage &theme = ctx->res->theme;
if (ctx->const_color) {
return theme.color_bone_solid;
return theme.colors.bone_solid;
}
const float *col = get_bone_solid_color(ctx, boneflag);
@@ -914,7 +914,7 @@ static const float *get_bone_wire_color(const Armatures::DrawContext *ctx,
copy_v3_v3(disp_color, ctx->const_color);
}
else {
const GlobalsUboStorage &theme = ctx->res->theme_settings;
const GlobalsUboStorage &theme = ctx->res->theme;
switch (ctx->draw_mode) {
case ARM_DRAW_MODE_EDIT:
get_pchan_color_wire(theme, ctx->bcolor, ctx->draw_mode, boneflag, disp_color);
@@ -927,7 +927,7 @@ static const float *get_bone_wire_color(const Armatures::DrawContext *ctx,
}
break;
case ARM_DRAW_MODE_OBJECT:
copy_v3_v3(disp_color, theme.color_vertex);
copy_v3_v3(disp_color, theme.colors.vert);
break;
}
}
@@ -952,7 +952,7 @@ static const float *get_bone_hint_color(const Armatures::DrawContext *ctx,
static float hint_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
if (ctx->const_color) {
bone_hint_color_shade(hint_color, ctx->res->theme_settings.color_bone_solid);
bone_hint_color_shade(hint_color, ctx->res->theme.colors.bone_solid);
}
else {
const float *wire_color = get_bone_wire_color(ctx, boneflag);
@@ -1223,8 +1223,8 @@ static void draw_axes(const Armatures::DrawContext *ctx,
{
float final_col[4];
const float *col = (ctx->const_color) ? ctx->const_color :
(bone.flag() & BONE_SELECTED) ? &ctx->res->theme_settings.color_text_hi.x :
&ctx->res->theme_settings.color_text.x;
(bone.flag() & BONE_SELECTED) ? &ctx->res->theme.colors.text_hi.x :
&ctx->res->theme.colors.text.x;
copy_v4_v4(final_col, col);
/* Mix with axes color. */
final_col[3] = (ctx->const_color) ? 1.0 : (bone.flag() & BONE_SELECTED) ? 0.1 : 0.65;
@@ -1259,10 +1259,10 @@ static void draw_points(const Armatures::DrawContext *ctx,
float col_wire_root[4], col_wire_tail[4];
float col_hint_root[4], col_hint_tail[4];
const GlobalsUboStorage &theme = ctx->res->theme_settings;
const GlobalsUboStorage &theme = ctx->res->theme;
copy_v4_v4(col_wire_root, (ctx->const_color) ? ctx->const_color : &theme.color_vertex.x);
copy_v4_v4(col_wire_tail, (ctx->const_color) ? ctx->const_color : &theme.color_vertex.x);
copy_v4_v4(col_wire_root, (ctx->const_color) ? ctx->const_color : &theme.colors.vert.x);
copy_v4_v4(col_wire_tail, (ctx->const_color) ? ctx->const_color : &theme.colors.vert.x);
const bool is_envelope_draw = (ctx->drawtype == ARM_ENVELOPE);
const float envelope_ignore = -1.0f;
@@ -1273,10 +1273,10 @@ static void draw_points(const Armatures::DrawContext *ctx,
if (ctx->draw_mode == ARM_DRAW_MODE_EDIT) {
const EditBone *eBone = bone.as_editbone();
if (eBone->flag & BONE_ROOTSEL) {
copy_v3_v3(col_wire_root, theme.color_vertex_select);
copy_v3_v3(col_wire_root, theme.colors.vert_select);
}
if (eBone->flag & BONE_TIPSEL) {
copy_v3_v3(col_wire_tail, theme.color_vertex_select);
copy_v3_v3(col_wire_tail, theme.colors.vert_select);
}
}
else if (ctx->draw_mode == ARM_DRAW_MODE_POSE) {
@@ -1285,10 +1285,12 @@ static void draw_points(const Armatures::DrawContext *ctx,
copy_v4_v4(col_wire_root, wire_color);
}
const float *hint_color_shade_root = (ctx->const_color) ? (const float *)theme.color_bone_solid :
col_wire_root;
const float *hint_color_shade_tail = (ctx->const_color) ? (const float *)theme.color_bone_solid :
col_wire_tail;
const float *hint_color_shade_root = (ctx->const_color) ?
(const float *)theme.colors.bone_solid :
col_wire_root;
const float *hint_color_shade_tail = (ctx->const_color) ?
(const float *)theme.colors.bone_solid :
col_wire_tail;
bone_hint_color_shade(col_hint_root, hint_color_shade_root);
bone_hint_color_shade(col_hint_tail, hint_color_shade_tail);
@@ -1743,17 +1745,17 @@ class ArmatureBoneDrawStrategyLine : public ArmatureBoneDrawStrategy {
col_bone = col_head = col_tail = ctx->const_color;
}
else {
const GlobalsUboStorage &theme = ctx->res->theme_settings;
const GlobalsUboStorage &theme = ctx->res->theme;
if (bone.is_editbone() && bone.flag() & BONE_TIPSEL) {
col_tail = &theme.color_vertex_select.x;
col_tail = &theme.colors.vert_select.x;
}
/* Draw root point if we are not connected to our parent. */
if (!(bone.has_parent() && (boneflag & BONE_CONNECTED))) {
if (bone.is_editbone()) {
col_head = (bone.flag() & BONE_ROOTSEL) ? &theme.color_vertex_select.x : col_bone;
col_head = (bone.flag() & BONE_ROOTSEL) ? &theme.colors.vert_select.x : col_bone;
}
else {
col_head = col_bone;

View File

@@ -83,7 +83,7 @@ class Background : Overlay {
bg_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA | DRW_STATE_CULL_BACK);
bg_ps_.shader_set(res.shaders->background_clip_bound.get());
bg_ps_.push_constant("ucolor", res.theme_settings.color_clipping_border);
bg_ps_.push_constant("ucolor", res.theme.colors.clipping_border);
bg_ps_.push_constant("boundbox", bbox.data(), 8);
bg_ps_.draw(res.shapes.cube_solid.get());
}

View File

@@ -434,8 +434,8 @@ class Cameras : Overlay {
int track_index = 1;
float4 bundle_color_custom;
float *bundle_color_solid = res.theme_settings.color_bundle_solid;
float *bundle_color_unselected = res.theme_settings.color_wire;
float *bundle_color_solid = res.theme.colors.bundle_solid;
float *bundle_color_unselected = res.theme.colors.wire;
uchar4 text_color_selected, text_color_unselected;
/* Color Management: Exception here as texts are drawn in sRGB space directly. */
UI_GetThemeColor4ubv(TH_SELECT, text_color_selected);
@@ -812,7 +812,7 @@ class Cameras : Overlay {
/* Connecting line between cameras. */
call_buffers_.stereo_connect_lines.append(stereodata.matrix.location(),
instdata.object_to_world.location(),
res.theme_settings.color_wire,
res.theme.colors.wire,
cam_select_id);
}

View File

@@ -216,8 +216,7 @@ class EditText : Overlay {
for (const int i : IndexRange(cu.totbox)) {
const TextBox &tb = cu.tb[i];
const bool is_active = (i == (cu.actbox - 1));
const float4 &color = is_active ? res.theme_settings.color_active :
res.theme_settings.color_wire;
const float4 &color = is_active ? res.theme.colors.active : res.theme.colors.wire;
if ((tb.w != 0.0f) || (tb.h != 0.0f)) {
const float3 top_left = float3(cu.xof + tb.x, cu.yof + tb.y + cu.fsize_realtime, 0.001);

View File

@@ -69,7 +69,7 @@ class Grid : Overlay {
auto &sub = grid_ps_.sub("grid_background");
sub.shader_set(res.shaders->grid_background.get());
const float4 color_back = math::interpolate(
res.theme_settings.color_background, res.theme_settings.color_grid, 0.5);
res.theme.colors.background, res.theme.colors.grid, 0.5);
sub.push_constant("ucolor", color_back);
sub.push_constant("tile_scale", float3(data_.size));
sub.bind_texture("depth_buffer", depth_tx);

View File

@@ -235,180 +235,187 @@ void Resources::update_clip_planes(const State &state)
void Resources::update_theme_settings(const DRWContext *ctx, const State &state)
{
using namespace math;
GlobalsUboStorage *gb = &theme_settings;
GlobalsUboStorage &gb = theme;
auto rgba_uchar_to_float = [](uchar r, uchar b, uchar g, uchar a) {
return float4(r, g, b, a) / 255.0f;
};
UI_GetThemeColor4fv(TH_WIRE, gb->color_wire);
UI_GetThemeColor4fv(TH_WIRE_EDIT, gb->color_wire_edit);
UI_GetThemeColor4fv(TH_ACTIVE, gb->color_active);
UI_GetThemeColor4fv(TH_SELECT, gb->color_select);
gb->color_library_select = rgba_uchar_to_float(0x88, 0xFF, 0xFF, 155);
gb->color_library = rgba_uchar_to_float(0x55, 0xCC, 0xCC, 155);
UI_GetThemeColor4fv(TH_TRANSFORM, gb->color_transform);
UI_GetThemeColor4fv(TH_LIGHT, gb->color_light);
UI_GetThemeColor4fv(TH_SPEAKER, gb->color_speaker);
UI_GetThemeColor4fv(TH_CAMERA, gb->color_camera);
UI_GetThemeColor4fv(TH_CAMERA_PATH, gb->color_camera_path);
UI_GetThemeColor4fv(TH_EMPTY, gb->color_empty);
UI_GetThemeColor4fv(TH_VERTEX, gb->color_vertex);
UI_GetThemeColor4fv(TH_VERTEX_SELECT, gb->color_vertex_select);
UI_GetThemeColor4fv(TH_VERTEX_UNREFERENCED, gb->color_vertex_unreferenced);
gb->color_vertex_missing_data = rgba_uchar_to_float(0xB0, 0x00, 0xB0, 0xFF);
UI_GetThemeColor4fv(TH_EDITMESH_ACTIVE, gb->color_edit_mesh_active);
UI_GetThemeColor4fv(TH_EDGE_SELECT, gb->color_edge_select);
UI_GetThemeColor4fv(TH_EDGE_MODE_SELECT, gb->color_edge_mode_select);
UI_GetThemeColor4fv(TH_GP_VERTEX, gb->color_gpencil_vertex);
UI_GetThemeColor4fv(TH_GP_VERTEX_SELECT, gb->color_gpencil_vertex_select);
UI_GetThemeColor4fv(TH_WIRE, gb.colors.wire);
UI_GetThemeColor4fv(TH_WIRE_EDIT, gb.colors.wire_edit);
UI_GetThemeColor4fv(TH_ACTIVE, gb.colors.active);
UI_GetThemeColor4fv(TH_SELECT, gb.colors.select);
gb.colors.library_select = rgba_uchar_to_float(0x88, 0xFF, 0xFF, 155);
gb.colors.library = rgba_uchar_to_float(0x55, 0xCC, 0xCC, 155);
UI_GetThemeColor4fv(TH_TRANSFORM, gb.colors.transform);
UI_GetThemeColor4fv(TH_LIGHT, gb.colors.light);
UI_GetThemeColor4fv(TH_SPEAKER, gb.colors.speaker);
UI_GetThemeColor4fv(TH_CAMERA, gb.colors.camera);
UI_GetThemeColor4fv(TH_CAMERA_PATH, gb.colors.camera_path);
UI_GetThemeColor4fv(TH_EMPTY, gb.colors.empty);
UI_GetThemeColor4fv(TH_VERTEX, gb.colors.vert);
UI_GetThemeColor4fv(TH_VERTEX_SELECT, gb.colors.vert_select);
UI_GetThemeColor4fv(TH_VERTEX_UNREFERENCED, gb.colors.vert_unreferenced);
gb.colors.vert_missing_data = rgba_uchar_to_float(0xB0, 0x00, 0xB0, 0xFF);
UI_GetThemeColor4fv(TH_EDITMESH_ACTIVE, gb.colors.edit_mesh_active);
UI_GetThemeColor4fv(TH_EDGE_SELECT, gb.colors.edge_select);
UI_GetThemeColor4fv(TH_EDGE_MODE_SELECT, gb.colors.edge_mode_select);
UI_GetThemeColor4fv(TH_GP_VERTEX, gb.colors.gpencil_vertex);
UI_GetThemeColor4fv(TH_GP_VERTEX_SELECT, gb.colors.gpencil_vertex_select);
UI_GetThemeColor4fv(TH_EDGE_SEAM, gb->color_edge_seam);
UI_GetThemeColor4fv(TH_EDGE_SHARP, gb->color_edge_sharp);
UI_GetThemeColor4fv(TH_EDGE_CREASE, gb->color_edge_crease);
UI_GetThemeColor4fv(TH_EDGE_BEVEL, gb->color_edge_bweight);
UI_GetThemeColor4fv(TH_EDGE_FACESEL, gb->color_edge_face_select);
UI_GetThemeColor4fv(TH_FACE, gb->color_face);
UI_GetThemeColor4fv(TH_FACE_SELECT, gb->color_face_select);
UI_GetThemeColor4fv(TH_FACE_MODE_SELECT, gb->color_face_mode_select);
UI_GetThemeColor4fv(TH_FACE_RETOPOLOGY, gb->color_face_retopology);
UI_GetThemeColor4fv(TH_FACE_BACK, gb->color_face_back);
UI_GetThemeColor4fv(TH_FACE_FRONT, gb->color_face_front);
UI_GetThemeColor4fv(TH_NORMAL, gb->color_normal);
UI_GetThemeColor4fv(TH_VNORMAL, gb->color_vnormal);
UI_GetThemeColor4fv(TH_LNORMAL, gb->color_lnormal);
UI_GetThemeColor4fv(TH_FACE_DOT, gb->color_facedot);
UI_GetThemeColor4fv(TH_SKIN_ROOT, gb->color_skinroot);
UI_GetThemeColor4fv(TH_BACK, gb->color_background);
UI_GetThemeColor4fv(TH_BACK_GRAD, gb->color_background_gradient);
UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_PRIMARY, gb->color_checker_primary);
UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_SECONDARY, gb->color_checker_secondary);
gb->size_checker = UI_GetThemeValuef(TH_TRANSPARENT_CHECKER_SIZE);
gb->fresnel_mix_edit = ((U.gpu_flag & USER_GPU_FLAG_FRESNEL_EDIT) == 0) ? 0.0f : 1.0f;
UI_GetThemeColor4fv(TH_V3D_CLIPPING_BORDER, gb->color_clipping_border);
UI_GetThemeColor4fv(TH_EDGE_SEAM, gb.colors.edge_seam);
UI_GetThemeColor4fv(TH_EDGE_SHARP, gb.colors.edge_sharp);
UI_GetThemeColor4fv(TH_EDGE_CREASE, gb.colors.edge_crease);
UI_GetThemeColor4fv(TH_EDGE_BEVEL, gb.colors.edge_bweight);
UI_GetThemeColor4fv(TH_EDGE_FACESEL, gb.colors.edge_face_select);
UI_GetThemeColor4fv(TH_FACE, gb.colors.face);
UI_GetThemeColor4fv(TH_FACE_SELECT, gb.colors.face_select);
UI_GetThemeColor4fv(TH_FACE_MODE_SELECT, gb.colors.face_mode_select);
UI_GetThemeColor4fv(TH_FACE_RETOPOLOGY, gb.colors.face_retopology);
UI_GetThemeColor4fv(TH_FACE_BACK, gb.colors.face_back);
UI_GetThemeColor4fv(TH_FACE_FRONT, gb.colors.face_front);
UI_GetThemeColor4fv(TH_NORMAL, gb.colors.normal);
UI_GetThemeColor4fv(TH_VNORMAL, gb.colors.vnormal);
UI_GetThemeColor4fv(TH_LNORMAL, gb.colors.lnormal);
UI_GetThemeColor4fv(TH_FACE_DOT, gb.colors.facedot);
UI_GetThemeColor4fv(TH_SKIN_ROOT, gb.colors.skinroot);
UI_GetThemeColor4fv(TH_BACK, gb.colors.background);
UI_GetThemeColor4fv(TH_BACK_GRAD, gb.colors.background_gradient);
UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_PRIMARY, gb.colors.checker_primary);
UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_SECONDARY, gb.colors.checker_secondary);
gb.sizes.checker = UI_GetThemeValuef(TH_TRANSPARENT_CHECKER_SIZE);
gb.fresnel_mix_edit = ((U.gpu_flag & USER_GPU_FLAG_FRESNEL_EDIT) == 0) ? 0.0f : 1.0f;
UI_GetThemeColor4fv(TH_V3D_CLIPPING_BORDER, gb.colors.clipping_border);
/* Custom median color to slightly affect the edit mesh colors. */
gb->color_edit_mesh_middle = interpolate(gb->color_vertex_select, gb->color_wire_edit, 0.35f);
gb.colors.edit_mesh_middle = interpolate(gb.colors.vert_select, gb.colors.wire_edit, 0.35f);
/* Desaturate. */
gb->color_edit_mesh_middle = float4(
float3(dot(gb->color_edit_mesh_middle.xyz(), float3(0.3333f))),
gb->color_edit_mesh_middle.w);
gb.colors.edit_mesh_middle = float4(
float3(dot(gb.colors.edit_mesh_middle.xyz(), float3(0.3333f))),
gb.colors.edit_mesh_middle.w);
#ifdef WITH_FREESTYLE
UI_GetThemeColor4fv(TH_FREESTYLE_EDGE_MARK, gb->color_edge_freestyle);
UI_GetThemeColor4fv(TH_FREESTYLE_FACE_MARK, gb->color_face_freestyle);
UI_GetThemeColor4fv(TH_FREESTYLE_EDGE_MARK, gb.colors.edge_freestyle);
UI_GetThemeColor4fv(TH_FREESTYLE_FACE_MARK, gb.colors.face_freestyle);
#else
gb->color_edge_freestyle = float4(0.0f);
gb->color_face_freestyle = float4(0.0f);
gb.colors.edge_freestyle = float4(0.0f);
gb.colors.face_freestyle = float4(0.0f);
#endif
UI_GetThemeColor4fv(TH_TEXT, gb->color_text);
UI_GetThemeColor4fv(TH_TEXT_HI, gb->color_text_hi);
UI_GetThemeColor4fv(TH_TEXT, gb.colors.text);
UI_GetThemeColor4fv(TH_TEXT_HI, gb.colors.text_hi);
/* Bone colors */
UI_GetThemeColor4fv(TH_BONE_POSE, gb->color_bone_pose);
UI_GetThemeColor4fv(TH_BONE_POSE_ACTIVE, gb->color_bone_pose_active);
UI_GetThemeColorShade4fv(TH_EDGE_SELECT, 60, gb->color_bone_active);
UI_GetThemeColorShade4fv(TH_EDGE_SELECT, -20, gb->color_bone_select);
UI_GetThemeColorBlendShade4fv(TH_WIRE, TH_BONE_POSE, 0.15f, 0, gb->color_bone_pose_active_unsel);
UI_GetThemeColor4fv(TH_BONE_POSE, gb.colors.bone_pose);
UI_GetThemeColor4fv(TH_BONE_POSE_ACTIVE, gb.colors.bone_pose_active);
UI_GetThemeColorShade4fv(TH_EDGE_SELECT, 60, gb.colors.bone_active);
UI_GetThemeColorShade4fv(TH_EDGE_SELECT, -20, gb.colors.bone_select);
UI_GetThemeColorBlendShade4fv(TH_WIRE, TH_BONE_POSE, 0.15f, 0, gb.colors.bone_pose_active_unsel);
UI_GetThemeColorBlendShade3fv(
TH_WIRE_EDIT, TH_EDGE_SELECT, 0.15f, 0, gb->color_bone_active_unsel);
gb->color_bone_pose_no_target = rgba_uchar_to_float(255, 150, 0, 80);
gb->color_bone_pose_ik = rgba_uchar_to_float(255, 255, 0, 80);
gb->color_bone_pose_spline_ik = rgba_uchar_to_float(200, 255, 0, 80);
gb->color_bone_pose_constraint = rgba_uchar_to_float(0, 255, 120, 80);
UI_GetThemeColor4fv(TH_BONE_SOLID, gb->color_bone_solid);
UI_GetThemeColor4fv(TH_BONE_LOCKED_WEIGHT, gb->color_bone_locked);
gb->color_bone_ik_line = float4(0.8f, 0.8f, 0.0f, 1.0f);
gb->color_bone_ik_line_no_target = float4(0.8f, 0.5f, 0.2f, 1.0f);
gb->color_bone_ik_line_spline = float4(0.8f, 0.8f, 0.2f, 1.0f);
TH_WIRE_EDIT, TH_EDGE_SELECT, 0.15f, 0, gb.colors.bone_active_unsel);
gb.colors.bone_pose_no_target = rgba_uchar_to_float(255, 150, 0, 80);
gb.colors.bone_pose_ik = rgba_uchar_to_float(255, 255, 0, 80);
gb.colors.bone_pose_spline_ik = rgba_uchar_to_float(200, 255, 0, 80);
gb.colors.bone_pose_constraint = rgba_uchar_to_float(0, 255, 120, 80);
UI_GetThemeColor4fv(TH_BONE_SOLID, gb.colors.bone_solid);
UI_GetThemeColor4fv(TH_BONE_LOCKED_WEIGHT, gb.colors.bone_locked);
gb.colors.bone_ik_line = float4(0.8f, 0.8f, 0.0f, 1.0f);
gb.colors.bone_ik_line_no_target = float4(0.8f, 0.5f, 0.2f, 1.0f);
gb.colors.bone_ik_line_spline = float4(0.8f, 0.8f, 0.2f, 1.0f);
/* Curve */
UI_GetThemeColor4fv(TH_HANDLE_FREE, gb->color_handle_free);
UI_GetThemeColor4fv(TH_HANDLE_AUTO, gb->color_handle_auto);
UI_GetThemeColor4fv(TH_HANDLE_VECT, gb->color_handle_vect);
UI_GetThemeColor4fv(TH_HANDLE_ALIGN, gb->color_handle_align);
UI_GetThemeColor4fv(TH_HANDLE_AUTOCLAMP, gb->color_handle_autoclamp);
UI_GetThemeColor4fv(TH_HANDLE_SEL_FREE, gb->color_handle_sel_free);
UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTO, gb->color_handle_sel_auto);
UI_GetThemeColor4fv(TH_HANDLE_SEL_VECT, gb->color_handle_sel_vect);
UI_GetThemeColor4fv(TH_HANDLE_SEL_ALIGN, gb->color_handle_sel_align);
UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTOCLAMP, gb->color_handle_sel_autoclamp);
UI_GetThemeColor4fv(TH_NURB_ULINE, gb->color_nurb_uline);
UI_GetThemeColor4fv(TH_NURB_VLINE, gb->color_nurb_vline);
UI_GetThemeColor4fv(TH_NURB_SEL_ULINE, gb->color_nurb_sel_uline);
UI_GetThemeColor4fv(TH_NURB_SEL_VLINE, gb->color_nurb_sel_vline);
UI_GetThemeColor4fv(TH_ACTIVE_SPLINE, gb->color_active_spline);
UI_GetThemeColor4fv(TH_HANDLE_FREE, gb.colors.handle_free);
UI_GetThemeColor4fv(TH_HANDLE_AUTO, gb.colors.handle_auto);
UI_GetThemeColor4fv(TH_HANDLE_VECT, gb.colors.handle_vect);
UI_GetThemeColor4fv(TH_HANDLE_ALIGN, gb.colors.handle_align);
UI_GetThemeColor4fv(TH_HANDLE_AUTOCLAMP, gb.colors.handle_autoclamp);
UI_GetThemeColor4fv(TH_HANDLE_SEL_FREE, gb.colors.handle_sel_free);
UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTO, gb.colors.handle_sel_auto);
UI_GetThemeColor4fv(TH_HANDLE_SEL_VECT, gb.colors.handle_sel_vect);
UI_GetThemeColor4fv(TH_HANDLE_SEL_ALIGN, gb.colors.handle_sel_align);
UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTOCLAMP, gb.colors.handle_sel_autoclamp);
UI_GetThemeColor4fv(TH_NURB_ULINE, gb.colors.nurb_uline);
UI_GetThemeColor4fv(TH_NURB_VLINE, gb.colors.nurb_vline);
UI_GetThemeColor4fv(TH_NURB_SEL_ULINE, gb.colors.nurb_sel_uline);
UI_GetThemeColor4fv(TH_NURB_SEL_VLINE, gb.colors.nurb_sel_vline);
UI_GetThemeColor4fv(TH_ACTIVE_SPLINE, gb.colors.active_spline);
UI_GetThemeColor4fv(TH_CFRAME, gb->color_current_frame);
UI_GetThemeColor4fv(TH_FRAME_BEFORE, gb->color_before_frame);
UI_GetThemeColor4fv(TH_FRAME_AFTER, gb->color_after_frame);
UI_GetThemeColor4fv(TH_CFRAME, gb.colors.current_frame);
UI_GetThemeColor4fv(TH_FRAME_BEFORE, gb.colors.before_frame);
UI_GetThemeColor4fv(TH_FRAME_AFTER, gb.colors.after_frame);
/* Meta-ball. */
gb->color_mball_radius = rgba_uchar_to_float(0xA0, 0x30, 0x30, 0xFF);
gb->color_mball_radius_select = rgba_uchar_to_float(0xF0, 0xA0, 0xA0, 0xFF);
gb->color_mball_stiffness = rgba_uchar_to_float(0x30, 0xA0, 0x30, 0xFF);
gb->color_mball_stiffness_select = rgba_uchar_to_float(0xA0, 0xF0, 0xA0, 0xFF);
gb.colors.mball_radius = rgba_uchar_to_float(0xA0, 0x30, 0x30, 0xFF);
gb.colors.mball_radius_select = rgba_uchar_to_float(0xF0, 0xA0, 0xA0, 0xFF);
gb.colors.mball_stiffness = rgba_uchar_to_float(0x30, 0xA0, 0x30, 0xFF);
gb.colors.mball_stiffness_select = rgba_uchar_to_float(0xA0, 0xF0, 0xA0, 0xFF);
/* Grid */
UI_GetThemeColorShade4fv(TH_GRID, 10, gb->color_grid);
UI_GetThemeColorShade4fv(TH_GRID, 10, gb.colors.grid);
/* Emphasize division lines lighter instead of darker, if background is darker than grid. */
const bool is_bg_darker = reduce_add(gb->color_grid.xyz()) + 0.12f >
reduce_add(gb->color_background.xyz());
UI_GetThemeColorShade4fv(TH_GRID, (is_bg_darker) ? 20 : -10, gb->color_grid_emphasis);
const bool is_bg_darker = reduce_add(gb.colors.grid.xyz()) + 0.12f >
reduce_add(gb.colors.background.xyz());
UI_GetThemeColorShade4fv(TH_GRID, (is_bg_darker) ? 20 : -10, gb.colors.grid_emphasis);
/* Grid Axis */
UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_X, 0.5f, -10, gb->color_grid_axis_x);
UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Y, 0.5f, -10, gb->color_grid_axis_y);
UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Z, 0.5f, -10, gb->color_grid_axis_z);
UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_X, 0.5f, -10, gb.colors.grid_axis_x);
UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Y, 0.5f, -10, gb.colors.grid_axis_y);
UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Z, 0.5f, -10, gb.colors.grid_axis_z);
UI_GetThemeColorShadeAlpha4fv(TH_TRANSFORM, 0, -80, gb->color_deselect);
UI_GetThemeColorShadeAlpha4fv(TH_WIRE, 0, -30, gb->color_outline);
UI_GetThemeColorShadeAlpha4fv(TH_LIGHT, 0, 255, gb->color_light_no_alpha);
UI_GetThemeColorShadeAlpha4fv(TH_TRANSFORM, 0, -80, gb.colors.deselect);
UI_GetThemeColorShadeAlpha4fv(TH_WIRE, 0, -30, gb.colors.outline);
UI_GetThemeColorShadeAlpha4fv(TH_LIGHT, 0, 255, gb.colors.light_no_alpha);
/* UV colors */
UI_GetThemeColor4fv(TH_UV_SHADOW, gb->color_uv_shadow);
gb->size_pixel = U.pixelsize;
gb->size_object_center = (UI_GetThemeValuef(TH_OBCENTER_DIA) + 1.0f) * U.pixelsize;
gb->size_light_center = (UI_GetThemeValuef(TH_OBCENTER_DIA) + 1.5f) * U.pixelsize;
gb->size_light_circle = U.pixelsize * 9.0f;
gb->size_light_circle_shadow = gb->size_light_circle + U.pixelsize * 3.0f;
/* M_SQRT2 to be at least the same size of the old square */
gb->size_vertex = vertex_size_get();
gb->size_vertex_gpencil = U.pixelsize * UI_GetThemeValuef(TH_GP_VERTEX_SIZE);
gb->size_face_dot = U.pixelsize * UI_GetThemeValuef(TH_FACEDOT_SIZE);
gb->size_edge = U.pixelsize * max_ff(1.0f, UI_GetThemeValuef(TH_EDGE_WIDTH)) / 2.0f;
gb->size_edge_fix = U.pixelsize * (0.5f + 2.0f * (1.0f * (gb->size_edge * float(M_SQRT1_2))));
gb->pixel_fac = (state.rv3d) ? state.rv3d->pixsize : 1.0f;
gb->size_viewport = float4(ctx->viewport_size_get(), 1.0f / ctx->viewport_size_get());
UI_GetThemeColor4fv(TH_UV_SHADOW, gb.colors.uv_shadow);
/* Color management. */
{
float *color = gb->UBO_FIRST_COLOR;
float4 *color = reinterpret_cast<float4 *>(&gb.colors);
float4 *color_end = color + (sizeof(gb.colors) / sizeof(float4));
do {
/* TODO: more accurate transform. */
srgb_to_linearrgb_v4(color, color);
color += 4;
} while (color <= gb->UBO_LAST_COLOR);
srgb_to_linearrgb_v4(&color->x, &color->x);
} while (++color <= color_end);
}
gb.sizes.pixel = 1.0f;
gb.sizes.object_center = UI_GetThemeValuef(TH_OBCENTER_DIA) + 1.0f;
gb.sizes.light_center = UI_GetThemeValuef(TH_OBCENTER_DIA) + 1.5f;
gb.sizes.light_circle = 9.0f;
gb.sizes.light_circle_shadow = (gb.sizes.light_circle + 3.0f);
/* M_SQRT2 to be at least the same size of the old square */
gb.sizes.vert = vertex_size_get();
gb.sizes.vertex_gpencil = UI_GetThemeValuef(TH_GP_VERTEX_SIZE);
gb.sizes.face_dot = UI_GetThemeValuef(TH_FACEDOT_SIZE);
gb.sizes.edge = max_ff(1.0f, UI_GetThemeValuef(TH_EDGE_WIDTH)) / 2.0f;
/* Pixel size. */
{
float *size = reinterpret_cast<float *>(&gb.sizes);
float *size_end = size + (sizeof(gb.sizes) / sizeof(float));
do {
*size *= U.pixelsize;
} while (++size <= size_end);
}
gb.pixel_fac = (state.rv3d) ? state.rv3d->pixsize : 1.0f;
gb.size_viewport = float4(ctx->viewport_size_get(), 1.0f / ctx->viewport_size_get());
if (state.v3d) {
const View3DShading &shading = state.v3d->shading;
gb->backface_culling = (shading.type == OB_SOLID) &&
(shading.flag & V3D_SHADING_BACKFACE_CULLING);
gb.backface_culling = (shading.type == OB_SOLID) &&
(shading.flag & V3D_SHADING_BACKFACE_CULLING);
if (is_selection() || state.is_depth_only_drawing) {
/* This is bad as this makes a solid mode setting affect material preview / render mode
* selection and auto-depth. But users are relying on this to work in scene using backface
* culling in shading (see #136335 and #136418). */
gb->backface_culling = (shading.flag & V3D_SHADING_BACKFACE_CULLING);
gb.backface_culling = (shading.flag & V3D_SHADING_BACKFACE_CULLING);
}
}
else {
gb->backface_culling = false;
gb.backface_culling = false;
}
globals_buf.push_update();

View File

@@ -44,10 +44,10 @@ class Metaballs : Overlay {
const MetaBall &mb = DRW_object_get_data_for_drawing<MetaBall>(*ob);
const float *color;
const float *col_radius = res.theme_settings.color_mball_radius;
const float *col_radius_select = res.theme_settings.color_mball_radius_select;
const float *col_stiffness = res.theme_settings.color_mball_stiffness;
const float *col_stiffness_select = res.theme_settings.color_mball_stiffness_select;
const float *col_radius = res.theme.colors.mball_radius;
const float *col_radius_select = res.theme.colors.mball_radius_select;
const float *col_stiffness = res.theme.colors.mball_stiffness;
const float *col_stiffness_select = res.theme.colors.mball_stiffness_select;
int elem_num = 0;
LISTBASE_FOREACH (MetaElem *, ml, mb.editelems) {

View File

@@ -58,19 +58,17 @@ class Origins : Overlay {
if (ob == BKE_view_layer_active_object_get(state.view_layer)) {
select_buf_.select_append(res.select_id(ob_ref));
point_buf_.append(VertexData{location, res.theme_settings.color_active});
point_buf_.append(VertexData{location, res.theme.colors.active});
}
else if (ob->base_flag & BASE_SELECTED) {
select_buf_.select_append(res.select_id(ob_ref));
point_buf_.append(VertexData{location,
is_library ? res.theme_settings.color_library_select :
res.theme_settings.color_select});
point_buf_.append(VertexData{
location, is_library ? res.theme.colors.library_select : res.theme.colors.select});
}
else if (state.v3d_flag & V3D_DRAW_CENTERS) {
select_buf_.select_append(res.select_id(ob_ref));
point_buf_.append(VertexData{location,
is_library ? res.theme_settings.color_library :
res.theme_settings.color_deselect});
point_buf_.append(
VertexData{location, is_library ? res.theme.colors.library : res.theme.colors.deselect});
}
}

View File

@@ -85,7 +85,7 @@ class Prepass : Overlay {
use_material_slot_selection_ = state.is_material_select;
bool use_cull = res.theme_settings.backface_culling;
bool use_cull = res.globals_buf.backface_culling;
DRWState backface_cull_state = use_cull ? DRW_STATE_CULL_BACK : DRWState(0);
ps_.init();

View File

@@ -679,7 +679,7 @@ struct Resources : public select::SelectMap {
int64_t depth_planes_count = 0;
draw::UniformBuffer<GlobalsUboStorage> globals_buf;
GlobalsUboStorage &theme_settings = globals_buf;
GlobalsUboStorage &theme = globals_buf;
draw::UniformArrayBuffer<float4, 6> clip_planes_buf;
/* Wrappers around #DefaultTextureList members. */
TextureRef depth_in_front_tx;
@@ -864,27 +864,27 @@ struct Resources : public select::SelectMap {
const float4 &object_wire_color(const ObjectRef &ob_ref, ThemeColorID theme_id) const
{
if (UNLIKELY(ob_ref.object->base_flag & BASE_FROM_SET)) {
return theme_settings.color_wire;
return theme.colors.wire;
}
switch (theme_id) {
case TH_WIRE_EDIT:
return theme_settings.color_wire_edit;
return theme.colors.wire_edit;
case TH_ACTIVE:
return theme_settings.color_active;
return theme.colors.active;
case TH_SELECT:
return theme_settings.color_select;
return theme.colors.select;
case TH_TRANSFORM:
return theme_settings.color_transform;
return theme.colors.transform;
case TH_SPEAKER:
return theme_settings.color_speaker;
return theme.colors.speaker;
case TH_CAMERA:
return theme_settings.color_camera;
return theme.colors.camera;
case TH_EMPTY:
return theme_settings.color_empty;
return theme.colors.empty;
case TH_LIGHT:
return theme_settings.color_light;
return theme.colors.light;
default:
return theme_settings.color_wire;
return theme.colors.wire;
}
}
@@ -933,7 +933,7 @@ struct Resources : public select::SelectMap {
static float vertex_size_get()
{
/* M_SQRT2 to be at least the same size of the old square */
return U.pixelsize * max_ff(1.0f, UI_GetThemeValuef(TH_VERTEX_SIZE) * float(M_SQRT2) / 2.0f);
return max_ff(1.0f, UI_GetThemeValuef(TH_VERTEX_SIZE) * float(M_SQRT2) / 2.0f);
}
/** Convenience functions. */

View File

@@ -63,8 +63,8 @@ class Relations : Overlay {
}
Object *ob = ob_ref.object;
const float4 &relation_color = res.theme_settings.color_wire;
const float4 &constraint_color = res.theme_settings.color_grid_axis_z; /* ? */
const float4 &relation_color = res.theme.colors.wire;
const float4 &constraint_color = res.theme.colors.grid_axis_z; /* ? */
if (ob->parent && (DRW_object_visibility_in_active_context(ob->parent) & OB_VISIBLE_SELF)) {
const float3 &parent_pos = ob->runtime->parent_display_origin;

View File

@@ -108,15 +108,15 @@ float4 get_bezier_handle_color(uint color_id, float sel)
{
switch (color_id) {
case 0u: /* BEZIER_HANDLE_FREE */
return mix(globalsBlock.color_handle_free, globalsBlock.color_handle_sel_free, sel);
return mix(globalsBlock.colors.handle_free, globalsBlock.colors.handle_sel_free, sel);
case 1u: /* BEZIER_HANDLE_AUTO */
return mix(globalsBlock.color_handle_auto, globalsBlock.color_handle_sel_auto, sel);
return mix(globalsBlock.colors.handle_auto, globalsBlock.colors.handle_sel_auto, sel);
case 2u: /* BEZIER_HANDLE_VECTOR */
return mix(globalsBlock.color_handle_vect, globalsBlock.color_handle_sel_vect, sel);
return mix(globalsBlock.colors.handle_vect, globalsBlock.colors.handle_sel_vect, sel);
case 3u: /* BEZIER_HANDLE_ALIGN */
return mix(globalsBlock.color_handle_align, globalsBlock.color_handle_sel_align, sel);
return mix(globalsBlock.colors.handle_align, globalsBlock.colors.handle_sel_align, sel);
}
return mix(globalsBlock.color_handle_autoclamp, globalsBlock.color_handle_sel_autoclamp, sel);
return mix(globalsBlock.colors.handle_autoclamp, globalsBlock.colors.handle_sel_autoclamp, sel);
}
void geometry_main(VertOut geom_in[2],
@@ -154,13 +154,13 @@ void geometry_main(VertOut geom_in[2],
inner_color = get_bezier_handle_color(color_id, geom_in[line_end_point].sel);
}
else if ((geom_in[line_end_point].flag & EDIT_CURVES_NURBS_CONTROL_POINT) != 0u) {
inner_color = mix(globalsBlock.color_nurb_uline,
globalsBlock.color_nurb_sel_uline,
inner_color = mix(globalsBlock.colors.nurb_uline,
globalsBlock.colors.nurb_sel_uline,
geom_in[line_end_point].sel);
}
else {
inner_color = mix(
globalsBlock.color_wire, globalsBlock.color_vertex_select, geom_in[line_end_point].sel);
globalsBlock.colors.wire, globalsBlock.colors.vert_select, geom_in[line_end_point].sel);
}
/* Minimize active color bleeding on inner_color. */

View File

@@ -183,7 +183,8 @@ struct Instance : public DrawEngine {
select_id_vert_ps.init();
select_vert = nullptr;
if (e_data.context.select_mode & SCE_SELECT_VERTEX) {
const float vertex_size = blender::draw::overlay::Resources::vertex_size_get();
const float vertex_size = U.pixelsize *
blender::draw::overlay::Resources::vertex_size_get();
auto &sub = select_id_vert_ps.sub("Sub");
sub.state_set(state, clipping_plane_count);
sub.shader_set(sh->select_id_flat);

View File

@@ -10,255 +10,267 @@
#ifndef GPU_SHADER
# include "GPU_shader_shared_utils.hh"
typedef struct GlobalsUboStorage GlobalsUboStorage;
#endif
/* Future Plan: These globals were once shared between multiple overlay engines. But now that they
* have been merged into one engine, there is no reasons to keep these globals out of the overlay
* engine. */
#define UBO_FIRST_COLOR color_wire
#define UBO_LAST_COLOR color_uv_shadow
/* Used as UBO but colors can be directly referenced as well */
/* \note Also keep all color as float4 and between #UBO_FIRST_COLOR and #UBO_LAST_COLOR. */
struct GlobalsUboStorage {
/* All colors in this struct are converted to display linear RGB colorspace. */
struct ThemeColors {
/* UBOs data needs to be 16 byte aligned (size of float4) */
float4 color_wire;
float4 color_wire_edit;
float4 color_active;
float4 color_select;
float4 color_library_select;
float4 color_library;
float4 color_transform;
float4 color_light;
float4 color_speaker;
float4 color_camera;
float4 color_camera_path;
float4 color_empty;
float4 color_vertex;
float4 color_vertex_select;
float4 color_vertex_unreferenced;
float4 color_vertex_missing_data;
float4 color_edit_mesh_active;
float4 color_edge_select; /* Stands for edge selection, not edge select mode. */
float4 color_edge_mode_select; /* Stands for edge mode selection. */
float4 color_edge_seam;
float4 color_edge_sharp;
float4 color_edge_crease;
float4 color_edge_bweight;
float4 color_edge_face_select;
float4 color_edge_freestyle;
float4 color_face;
float4 color_face_select; /* Stands for face selection, not face select mode. */
float4 color_face_mode_select; /* Stands for face mode selection. */
float4 color_face_retopology;
float4 color_face_freestyle;
float4 color_gpencil_vertex;
float4 color_gpencil_vertex_select;
float4 color_normal;
float4 color_vnormal;
float4 color_lnormal;
float4 color_facedot;
float4 color_skinroot;
float4 wire;
float4 wire_edit;
float4 active;
float4 select;
float4 library_select;
float4 library;
float4 transform;
float4 light;
float4 speaker;
float4 camera;
float4 camera_path;
float4 empty;
float4 vert; /* "vertex" is reserved keyword in MSL. */
float4 vert_select;
float4 vert_unreferenced;
float4 vert_missing_data;
float4 edit_mesh_active;
float4 edge_select; /* Stands for edge selection, not edge select mode. */
float4 edge_mode_select; /* Stands for edge mode selection. */
float4 edge_seam;
float4 edge_sharp;
float4 edge_crease;
float4 edge_bweight;
float4 edge_face_select;
float4 edge_freestyle;
float4 face;
float4 face_select; /* Stands for face selection, not face select mode. */
float4 face_mode_select; /* Stands for face mode selection. */
float4 face_retopology;
float4 face_freestyle;
float4 gpencil_vertex;
float4 gpencil_vertex_select;
float4 normal;
float4 vnormal;
float4 lnormal;
float4 facedot;
float4 skinroot;
float4 color_deselect;
float4 color_outline;
float4 color_light_no_alpha;
float4 deselect;
float4 outline;
float4 light_no_alpha;
float4 color_background;
float4 color_background_gradient;
float4 color_checker_primary;
float4 color_checker_secondary;
float4 color_clipping_border;
float4 color_edit_mesh_middle;
float4 background;
float4 background_gradient;
float4 checker_primary;
float4 checker_secondary;
float4 clipping_border;
float4 edit_mesh_middle;
float4 color_handle_free;
float4 color_handle_auto;
float4 color_handle_vect;
float4 color_handle_align;
float4 color_handle_autoclamp;
float4 color_handle_sel_free;
float4 color_handle_sel_auto;
float4 color_handle_sel_vect;
float4 color_handle_sel_align;
float4 color_handle_sel_autoclamp;
float4 color_nurb_uline;
float4 color_nurb_vline;
float4 color_nurb_sel_uline;
float4 color_nurb_sel_vline;
float4 color_active_spline;
float4 handle_free;
float4 handle_auto;
float4 handle_vect;
float4 handle_align;
float4 handle_autoclamp;
float4 handle_sel_free;
float4 handle_sel_auto;
float4 handle_sel_vect;
float4 handle_sel_align;
float4 handle_sel_autoclamp;
float4 nurb_uline;
float4 nurb_vline;
float4 nurb_sel_uline;
float4 nurb_sel_vline;
float4 active_spline;
float4 color_bone_pose;
float4 color_bone_pose_active;
float4 color_bone_pose_active_unsel;
float4 color_bone_pose_constraint;
float4 color_bone_pose_ik;
float4 color_bone_pose_spline_ik;
float4 color_bone_pose_no_target;
float4 color_bone_solid;
float4 color_bone_locked;
float4 color_bone_active;
float4 color_bone_active_unsel;
float4 color_bone_select;
float4 color_bone_ik_line;
float4 color_bone_ik_line_no_target;
float4 color_bone_ik_line_spline;
float4 bone_pose;
float4 bone_pose_active;
float4 bone_pose_active_unsel;
float4 bone_pose_constraint;
float4 bone_pose_ik;
float4 bone_pose_spline_ik;
float4 bone_pose_no_target;
float4 bone_solid;
float4 bone_locked;
float4 bone_active;
float4 bone_active_unsel;
float4 bone_select;
float4 bone_ik_line;
float4 bone_ik_line_no_target;
float4 bone_ik_line_spline;
float4 color_text;
float4 color_text_hi;
float4 text;
float4 text_hi;
float4 color_bundle_solid;
float4 bundle_solid;
float4 color_mball_radius;
float4 color_mball_radius_select;
float4 color_mball_stiffness;
float4 color_mball_stiffness_select;
float4 mball_radius;
float4 mball_radius_select;
float4 mball_stiffness;
float4 mball_stiffness_select;
float4 color_current_frame;
float4 color_before_frame;
float4 color_after_frame;
float4 current_frame;
float4 before_frame;
float4 after_frame;
float4 color_grid;
float4 color_grid_emphasis;
float4 color_grid_axis_x;
float4 color_grid_axis_y;
float4 color_grid_axis_z;
float4 grid;
float4 grid_emphasis;
float4 grid_axis_x;
float4 grid_axis_y;
float4 grid_axis_z;
float4 color_face_back;
float4 color_face_front;
float4 face_back;
float4 face_front;
float4 color_uv_shadow;
float4 uv_shadow;
};
BLI_STATIC_ASSERT_ALIGN(ThemeColors, 16)
/* All values in this struct are premultiplied by U.pixelsize. */
struct ThemeSizes {
float pixel;
float object_center;
float light_center;
float light_circle;
float light_circle_shadow;
float vert; /* "vertex" is reserved keyword in MSL. */
float edge;
float face_dot;
float checker;
float vertex_gpencil;
float _pad1, _pad2;
};
BLI_STATIC_ASSERT_ALIGN(ThemeSizes, 16)
struct GlobalsUboStorage {
ThemeColors colors;
ThemeSizes sizes;
/** Other global states. */
/* NOTE: Put all color before #UBO_LAST_COLOR. */
float4 size_viewport; /* Packed as float4. */
/* Pack individual float at the end of the buffer to avoid alignment errors */
float size_pixel, pixel_fac;
float size_object_center, size_light_center, size_light_circle, size_light_circle_shadow;
float size_vertex, size_edge, size_edge_fix, size_face_dot;
float size_checker;
float size_vertex_gpencil;
float fresnel_mix_edit;
float pixel_fac;
bool32_t backface_culling;
float _pad1, _pad2;
float _pad1;
};
BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
#ifdef GPU_SHADER
/* Keep compatibility_with old global scope syntax. */
/* TODO(@fclem) Mass rename and remove the camel case. */
# define colorWire globalsBlock.color_wire
# define colorWireEdit globalsBlock.color_wire_edit
# define colorActive globalsBlock.color_active
# define colorSelect globalsBlock.color_select
# define colorLibrarySelect globalsBlock.color_library_select
# define colorLibrary globalsBlock.color_library
# define colorTransform globalsBlock.color_transform
# define colorLight globalsBlock.color_light
# define colorSpeaker globalsBlock.color_speaker
# define colorCamera globalsBlock.color_camera
# define colorCameraPath globalsBlock.color_camera_path
# define colorEmpty globalsBlock.color_empty
# define colorVertex globalsBlock.color_vertex
# define colorVertexSelect globalsBlock.color_vertex_select
# define colorVertexUnreferenced globalsBlock.color_vertex_unreferenced
# define colorVertexMissingData globalsBlock.color_vertex_missing_data
# define colorEditMeshActive globalsBlock.color_edit_mesh_active
# define colorEdgeSelect globalsBlock.color_edge_select
# define colorEdgeModeSelect globalsBlock.color_edge_mode_select
# define colorEdgeSeam globalsBlock.color_edge_seam
# define colorEdgeSharp globalsBlock.color_edge_sharp
# define colorEdgeCrease globalsBlock.color_edge_crease
# define colorEdgeBWeight globalsBlock.color_edge_bweight
# define colorEdgeFaceSelect globalsBlock.color_edge_face_select
# define colorEdgeFreestyle globalsBlock.color_edge_freestyle
# define colorFace globalsBlock.color_face
# define colorFaceSelect globalsBlock.color_face_select
# define colorFaceModeSelect globalsBlock.color_face_mode_select
# define colorFaceRetopology globalsBlock.color_face_retopology
# define colorFaceFreestyle globalsBlock.color_face_freestyle
# define colorGpencilVertex globalsBlock.color_gpencil_vertex
# define colorGpencilVertexSelect globalsBlock.color_gpencil_vertex_select
# define colorNormal globalsBlock.color_normal
# define colorVNormal globalsBlock.color_vnormal
# define colorLNormal globalsBlock.color_lnormal
# define colorFaceDot globalsBlock.color_facedot
# define colorSkinRoot globalsBlock.color_skinroot
# define colorDeselect globalsBlock.color_deselect
# define colorOutline globalsBlock.color_outline
# define colorLightNoAlpha globalsBlock.color_light_no_alpha
# define colorBackground globalsBlock.color_background
# define colorBackgroundGradient globalsBlock.color_background_gradient
# define colorCheckerPrimary globalsBlock.color_checker_primary
# define colorCheckerSecondary globalsBlock.color_checker_secondary
# define colorClippingBorder globalsBlock.color_clipping_border
# define colorEditMeshMiddle globalsBlock.color_edit_mesh_middle
# define colorHandleFree globalsBlock.color_handle_free
# define colorHandleAuto globalsBlock.color_handle_auto
# define colorHandleVect globalsBlock.color_handle_vect
# define colorHandleAlign globalsBlock.color_handle_align
# define colorHandleAutoclamp globalsBlock.color_handle_autoclamp
# define colorHandleSelFree globalsBlock.color_handle_sel_free
# define colorHandleSelAuto globalsBlock.color_handle_sel_auto
# define colorHandleSelVect globalsBlock.color_handle_sel_vect
# define colorHandleSelAlign globalsBlock.color_handle_sel_align
# define colorHandleSelAutoclamp globalsBlock.color_handle_sel_autoclamp
# define colorNurbUline globalsBlock.color_nurb_uline
# define colorNurbVline globalsBlock.color_nurb_vline
# define colorNurbSelUline globalsBlock.color_nurb_sel_uline
# define colorNurbSelVline globalsBlock.color_nurb_sel_vline
# define colorActiveSpline globalsBlock.color_active_spline
# define colorBonePose globalsBlock.color_bone_pose
# define colorBonePoseActive globalsBlock.color_bone_pose_active
# define colorBonePoseActiveUnsel globalsBlock.color_bone_pose_active_unsel
# define colorBonePoseConstraint globalsBlock.color_bone_pose_constraint
# define colorBonePoseIK globalsBlock.color_bone_pose_ik
# define colorBonePoseSplineIK globalsBlock.color_bone_pose_spline_ik
# define colorBonePoseTarget globalsBlock.color_bone_pose_no_target
# define colorBoneSolid globalsBlock.color_bone_solid
# define colorBoneLocked globalsBlock.color_bone_locked
# define colorBoneActive globalsBlock.color_bone_active
# define colorBoneActiveUnsel globalsBlock.color_bone_active_unsel
# define colorBoneSelect globalsBlock.color_bone_select
# define colorBoneIKLine globalsBlock.color_bone_ik_line
# define colorBoneIKLineNoTarget globalsBlock.color_bone_ik_line_no_target
# define colorBoneIKLineSpline globalsBlock.color_bone_ik_line_spline
# define colorText globalsBlock.color_text
# define colorTextHi globalsBlock.color_text_hi
# define colorBundleSolid globalsBlock.color_bundle_solid
# define colorMballRadius globalsBlock.color_mball_radius
# define colorMballRadiusSelect globalsBlock.color_mball_radius_select
# define colorMballStiffness globalsBlock.color_mball_stiffness
# define colorMballStiffnessSelect globalsBlock.color_mball_stiffness_select
# define colorCurrentFrame globalsBlock.color_current_frame
# define colorBeforeFrame globalsBlock.color_before_frame
# define colorAfterFrame globalsBlock.color_after_frame
# define colorGrid globalsBlock.color_grid
# define colorGridEmphasis globalsBlock.color_grid_emphasis
# define colorGridAxisX globalsBlock.color_grid_axis_x
# define colorGridAxisY globalsBlock.color_grid_axis_y
# define colorGridAxisZ globalsBlock.color_grid_axis_z
# define colorFaceBack globalsBlock.color_face_back
# define colorFaceFront globalsBlock.color_face_front
# define colorUVShadow globalsBlock.color_uv_shadow
# define colorWire globalsBlock.colors.wire
# define colorWireEdit globalsBlock.colors.wire_edit
# define colorActive globalsBlock.colors.active
# define colorSelect globalsBlock.colors.select
# define colorLibrarySelect globalsBlock.colors.library_select
# define colorLibrary globalsBlock.colors.library
# define colorTransform globalsBlock.colors.transform
# define colorLight globalsBlock.colors.light
# define colorSpeaker globalsBlock.colors.speaker
# define colorCamera globalsBlock.colors.camera
# define colorCameraPath globalsBlock.colors.camera_path
# define colorEmpty globalsBlock.colors.empty
# define colorVertex globalsBlock.colors.vert
# define colorVertexSelect globalsBlock.colors.vert_select
# define colorVertexUnreferenced globalsBlock.colors.vert_unreferenced
# define colorVertexMissingData globalsBlock.colors.vert_missing_data
# define colorEditMeshActive globalsBlock.colors.edit_mesh_active
# define colorEdgeSelect globalsBlock.colors.edge_select
# define colorEdgeModeSelect globalsBlock.colors.edge_mode_select
# define colorEdgeSeam globalsBlock.colors.edge_seam
# define colorEdgeSharp globalsBlock.colors.edge_sharp
# define colorEdgeCrease globalsBlock.colors.edge_crease
# define colorEdgeBWeight globalsBlock.colors.edge_bweight
# define colorEdgeFaceSelect globalsBlock.colors.edge_face_select
# define colorEdgeFreestyle globalsBlock.colors.edge_freestyle
# define colorFace globalsBlock.colors.face
# define colorFaceSelect globalsBlock.colors.face_select
# define colorFaceModeSelect globalsBlock.colors.face_mode_select
# define colorFaceRetopology globalsBlock.colors.face_retopology
# define colorFaceFreestyle globalsBlock.colors.face_freestyle
# define colorGpencilVertex globalsBlock.colors.gpencil_vertex
# define colorGpencilVertexSelect globalsBlock.colors.gpencil_vertex_select
# define colorNormal globalsBlock.colors.normal
# define colorVNormal globalsBlock.colors.vnormal
# define colorLNormal globalsBlock.colors.lnormal
# define colorFaceDot globalsBlock.colors.facedot
# define colorSkinRoot globalsBlock.colors.skinroot
# define colorDeselect globalsBlock.colors.deselect
# define colorOutline globalsBlock.colors.outline
# define colorLightNoAlpha globalsBlock.colors.light_no_alpha
# define colorBackground globalsBlock.colors.background
# define colorBackgroundGradient globalsBlock.colors.background_gradient
# define colorCheckerPrimary globalsBlock.colors.checker_primary
# define colorCheckerSecondary globalsBlock.colors.checker_secondary
# define colorClippingBorder globalsBlock.colors.clipping_border
# define colorEditMeshMiddle globalsBlock.colors.edit_mesh_middle
# define colorHandleFree globalsBlock.colors.handle_free
# define colorHandleAuto globalsBlock.colors.handle_auto
# define colorHandleVect globalsBlock.colors.handle_vect
# define colorHandleAlign globalsBlock.colors.handle_align
# define colorHandleAutoclamp globalsBlock.colors.handle_autoclamp
# define colorHandleSelFree globalsBlock.colors.handle_sel_free
# define colorHandleSelAuto globalsBlock.colors.handle_sel_auto
# define colorHandleSelVect globalsBlock.colors.handle_sel_vect
# define colorHandleSelAlign globalsBlock.colors.handle_sel_align
# define colorHandleSelAutoclamp globalsBlock.colors.handle_sel_autoclamp
# define colorNurbUline globalsBlock.colors.nurb_uline
# define colorNurbVline globalsBlock.colors.nurb_vline
# define colorNurbSelUline globalsBlock.colors.nurb_sel_uline
# define colorNurbSelVline globalsBlock.colors.nurb_sel_vline
# define colorActiveSpline globalsBlock.colors.active_spline
# define colorBonePose globalsBlock.colors.bone_pose
# define colorBonePoseActive globalsBlock.colors.bone_pose_active
# define colorBonePoseActiveUnsel globalsBlock.colors.bone_pose_active_unsel
# define colorBonePoseConstraint globalsBlock.colors.bone_pose_constraint
# define colorBonePoseIK globalsBlock.colors.bone_pose_ik
# define colorBonePoseSplineIK globalsBlock.colors.bone_pose_spline_ik
# define colorBonePoseTarget globalsBlock.colors.bone_pose_no_target
# define colorBoneSolid globalsBlock.colors.bone_solid
# define colorBoneLocked globalsBlock.colors.bone_locked
# define colorBoneActive globalsBlock.colors.bone_active
# define colorBoneActiveUnsel globalsBlock.colors.bone_active_unsel
# define colorBoneSelect globalsBlock.colors.bone_select
# define colorBoneIKLine globalsBlock.colors.bone_ik_line
# define colorBoneIKLineNoTarget globalsBlock.colors.bone_ik_line_no_target
# define colorBoneIKLineSpline globalsBlock.colors.bone_ik_line_spline
# define colorText globalsBlock.colors.text
# define colorTextHi globalsBlock.colors.text_hi
# define colorBundleSolid globalsBlock.colors.bundle_solid
# define colorMballRadius globalsBlock.colors.mball_radius
# define colorMballRadiusSelect globalsBlock.colors.mball_radius_select
# define colorMballStiffness globalsBlock.colors.mball_stiffness
# define colorMballStiffnessSelect globalsBlock.colors.mball_stiffness_select
# define colorCurrentFrame globalsBlock.colors.current_frame
# define colorBeforeFrame globalsBlock.colors.before_frame
# define colorAfterFrame globalsBlock.colors.after_frame
# define colorGrid globalsBlock.colors.grid
# define colorGridEmphasis globalsBlock.colors.grid_emphasis
# define colorGridAxisX globalsBlock.colors.grid_axis_x
# define colorGridAxisY globalsBlock.colors.grid_axis_y
# define colorGridAxisZ globalsBlock.colors.grid_axis_z
# define colorFaceBack globalsBlock.colors.face_back
# define colorFaceFront globalsBlock.colors.face_front
# define colorUVShadow globalsBlock.colors.uv_shadow
# define sizeViewport float2(globalsBlock.size_viewport.xy)
# define sizeViewportInv float2(globalsBlock.size_viewport.zw)
# define sizePixel globalsBlock.size_pixel
# define sizePixel globalsBlock.sizes.pixel
# define pixelFac globalsBlock.pixel_fac
# define sizeObjectCenter globalsBlock.size_object_center
# define sizeLightCenter globalsBlock.size_light_center
# define sizeLightCircle globalsBlock.size_light_circle
# define sizeLightCircleShadow globalsBlock.size_light_circle_shadow
# define sizeVertex globalsBlock.size_vertex
# define sizeEdge globalsBlock.size_edge
# define sizeEdgeFix globalsBlock.size_edge_fix
# define sizeFaceDot globalsBlock.size_face_dot
# define sizeChecker globalsBlock.size_checker
# define sizeVertexGpencil globalsBlock.size_vertex_gpencil
# define sizeObjectCenter globalsBlock.sizes.object_center
# define sizeLightCenter globalsBlock.sizes.light_center
# define sizeLightCircle globalsBlock.sizes.light_circle
# define sizeLightCircleShadow globalsBlock.sizes.light_circle_shadow
# define sizeVertex globalsBlock.sizes.vert
# define sizeEdge globalsBlock.sizes.edge
# define sizeFaceDot globalsBlock.sizes.face_dot
# define sizeChecker globalsBlock.sizes.checker
# define sizeVertexGpencil globalsBlock.sizes.vertex_gpencil
# define fresnelMixEdit globalsBlock.fresnel_mix_edit
#endif