Wip: Anim: Theme entry for time visualization #120558

Draft
Christoph Lendenfeld wants to merge 6 commits from ChrisLend/blender:theme_for_time_colors into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
15 changed files with 102 additions and 27 deletions

View File

@ -343,6 +343,8 @@ const bTheme U_theme_default = {
.bone_pose_active = RGBA(0x8cffff50),
.bone_locked_weight = RGBA(0xff000080),
.cframe = RGBA(0x4772b3ff),
.before_current_frame = RGBA(0xf22e23ff),
.after_current_frame = RGBA(0x78f244ff),
.time_keyframe = RGBA(0xddd700ff),
.time_gp_keyframe = RGBA(0xb5e61dff),
.freestyle_edge_mark = RGBA(0x7fff7fff),

View File

@ -539,19 +539,22 @@ class AnnotationOnionSkin:
gpl = context.active_annotation_layer
col = layout.column()
col.prop(gpl, "annotation_onion_use_custom_color")
split = col.split(factor=0.5)
split.active = gpl.use_annotation_onion_skinning
# - Before Frames
sub = split.column(align=True)
row = sub.row(align=True)
row.prop(gpl, "annotation_onion_before_color", text="")
if gpl.annotation_onion_use_custom_color:
row.prop(gpl, "annotation_onion_before_color", text="")
sub.prop(gpl, "annotation_onion_before_range", text="Before")
# - After Frames
sub = split.column(align=True)
row = sub.row(align=True)
row.prop(gpl, "annotation_onion_after_color", text="")
if gpl.annotation_onion_use_custom_color:
row.prop(gpl, "annotation_onion_after_color", text="")
sub.prop(gpl, "annotation_onion_after_range", text="After")

View File

@ -29,7 +29,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 41
#define BLENDER_FILE_SUBVERSION 42
/* 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

@ -160,6 +160,11 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
FROM_DEFAULT_V4_UCHAR(space_image.asset_shelf.header_back);
}
if (!USER_VERSION_ATLEAST(402, 42)) {
FROM_DEFAULT_V4_UCHAR(space_view3d.before_current_frame);
FROM_DEFAULT_V4_UCHAR(space_view3d.after_current_frame);
}
/**
* Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a USER_VERSION_ATLEAST check.

View File

@ -33,6 +33,8 @@
#include "DEG_depsgraph.hh"
#include "UI_resources.hh"
/* -------------------------------------------------------------------- */
/** \name Object
* \{ */
@ -239,9 +241,17 @@ static void gpencil_layer_final_tint_and_alpha_get(const GPENCIL_PrivateData *pd
const bool use_onion_fade = (gpd->onion_flag & GP_ONION_FADE) != 0;
const bool use_next_col = gpf->runtime.onion_id > 0.0f;
const float *onion_col_custom = (use_onion_custom_col) ?
(use_next_col ? gpd->gcolor_next : gpd->gcolor_prev) :
U.gpencil_new_layer_col;
float color_next[3];
float color_prev[3];
if (use_onion_custom_col) {
copy_v3_v3(color_next, gpd->gcolor_next);
copy_v3_v3(color_prev, gpd->gcolor_prev);
}
else {
UI_GetThemeColor3fv(TH_FRAME_AFTER, color_next);
UI_GetThemeColor3fv(TH_FRAME_BEFORE, color_prev);
}
const float *onion_col_custom = use_next_col ? color_next : color_prev;
copy_v4_fl4(r_tint, UNPACK3(onion_col_custom), 1.0f);
@ -275,13 +285,19 @@ static float4 grease_pencil_layer_final_tint_and_alpha_get(const GPENCIL_Private
const bool use_next_col = onion_id > 0;
const float onion_factor = grease_pencil.onion_skinning_settings.opacity;
const float3 color_next(grease_pencil.onion_skinning_settings.color_after);
const float3 color_prev(grease_pencil.onion_skinning_settings.color_before);
const float4 onion_col_custom = (use_onion_custom_col) ?
(use_next_col ? float4(color_next, 1.0f) :
float4(color_prev, 1.0f)) :
float4(U.gpencil_new_layer_col);
float3 color_next, color_prev;
if (use_onion_custom_col) {
color_next = float3(grease_pencil.onion_skinning_settings.color_after);
color_prev = float3(grease_pencil.onion_skinning_settings.color_before);
}
else {
UI_GetThemeColor3fv(TH_FRAME_AFTER, color_next);
UI_GetThemeColor3fv(TH_FRAME_BEFORE, color_prev);
}
const float4 onion_col_custom = use_next_col ? float4(color_next, 1.0f) :
float4(color_prev, 1.0f);
*r_alpha = use_onion_fade ? (1.0f / abs(onion_id)) : 0.5f;
*r_alpha *= onion_factor;

View File

@ -44,12 +44,12 @@ void main()
}
else {
if (selected) {
intensity = calc_intensity(frameStart, frame, frameCurrent, 0.25, 0.75);
intensity = calc_intensity(frameStart, frame, frameCurrent, 0.0, 1.0);
}
else {
intensity = calc_intensity(frameStart, frame, frameCurrent, 0.68, 0.92);
intensity = calc_intensity(frameStart, frame, frameCurrent, 0.0, 1.0);
}
interp.color.rgb = mix(colorWire.rgb, blend_base, intensity);
interp.color.rgb = colorBeforeFrame.rgb;
}
}
else if (frame > frameCurrent) {
@ -58,13 +58,13 @@ void main()
}
else {
if (selected) {
intensity = calc_intensity(frameCurrent, frame, frameEnd, 0.25, 0.75);
intensity = calc_intensity(frameCurrent, frame, frameEnd, 0.0, 1.0);
}
else {
intensity = calc_intensity(frameCurrent, frame, frameEnd, 0.68, 0.92);
intensity = calc_intensity(frameCurrent, frame, frameEnd, 0.0, 1.0);
}
interp.color.rgb = mix(colorBonePose.rgb, blend_base, intensity);
interp.color.rgb = colorAfterFrame.rgb;
}
}
else {
@ -79,7 +79,7 @@ void main()
else {
intensity = 0.75f;
}
interp.color.rgb = mix(colorBackground.rgb, blend_base, intensity);
interp.color.rgb = blend_base;
}
}

View File

@ -142,6 +142,8 @@ void DRW_globals_update()
UI_GetThemeColor4fv(TH_ACTIVE_SPLINE, gb->color_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);
/* Meta-ball. */
UI_COLOR_RGBA_FROM_U8(0xA0, 0x30, 0x30, 0xFF, gb->color_mball_radius);

View File

@ -115,6 +115,8 @@ struct GlobalsUboStorage {
float4 color_mball_stiffness_select;
float4 color_current_frame;
float4 color_before_frame;
float4 color_after_frame;
float4 color_grid;
float4 color_grid_emphasis;
@ -228,6 +230,8 @@ BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
# 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

View File

@ -41,6 +41,8 @@
#include "ED_screen.hh"
#include "ED_view3d.hh"
#include "UI_resources.hh"
/* ************************************************** */
/* GREASE PENCIL DRAWING */
@ -586,7 +588,12 @@ static void annotation_draw_onionskins(
float color[4];
/* 1) Draw Previous Frames First */
copy_v3_v3(color, gpl->gcolor_prev);
if (gpl->onion_flag & GP_LAYER_ONIONSKIN_CUSTOM_COLOR) {
copy_v3_v3(color, gpl->gcolor_prev);
}
else {
UI_GetThemeColor3fv(TH_FRAME_BEFORE, color);
}
if (gpl->gstep > 0) {
bGPDframe *gf;
@ -618,7 +625,12 @@ static void annotation_draw_onionskins(
}
/* 2) Now draw next frames */
copy_v3_v3(color, gpl->gcolor_next);
if (gpl->onion_flag & GP_LAYER_ONIONSKIN_CUSTOM_COLOR) {
copy_v3_v3(color, gpl->gcolor_next);
}
else {
UI_GetThemeColor3fv(TH_FRAME_AFTER, color);
}
if (gpl->gstep_next > 0) {
bGPDframe *gf;

View File

@ -108,6 +108,8 @@ enum ThemeColorID {
TH_FACE_DOT,
TH_FACEDOT_SIZE,
TH_CFRAME,
TH_FRAME_BEFORE,
TH_FRAME_AFTER,
TH_TIME_SCRUB_BACKGROUND,
TH_TIME_MARKER_LINE,
TH_TIME_MARKER_LINE_SELECTED,

View File

@ -520,6 +520,12 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
case TH_CFRAME:
cp = ts->cframe;
break;
case TH_FRAME_BEFORE:
cp = ts->before_current_frame;
break;
case TH_FRAME_AFTER:
cp = ts->after_current_frame;
break;
case TH_TIME_KEYFRAME:
cp = ts->time_keyframe;
break;

View File

@ -603,6 +603,7 @@ typedef enum eGPDlayer_Flag {
typedef enum eGPDlayer_OnionFlag {
/* do onion skinning */
GP_LAYER_ONIONSKIN = (1 << 0),
GP_LAYER_ONIONSKIN_CUSTOM_COLOR = (1 << 1),
} eGPDlayer_OnionFlag;
/** #bGPDlayer.blend_mode */

View File

@ -299,6 +299,7 @@ typedef struct ThemeSpace {
unsigned char bone_solid[4], bone_pose[4], bone_pose_active[4], bone_locked_weight[4];
unsigned char strip[4], strip_select[4];
unsigned char cframe[4];
unsigned char before_current_frame[4], after_current_frame[4];
unsigned char time_keyframe[4], time_gp_keyframe[4];
unsigned char freestyle_edge_mark[4], freestyle_face_mark[4];
unsigned char time_scrub_background[4];

View File

@ -2145,6 +2145,14 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "annotation_onion_use_custom_color", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "onion_flag", GP_LAYER_ONIONSKIN_CUSTOM_COLOR);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop,
"Custom Onion Skin Colors",
"Use custom colors for onion skinning instead of the theme");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
/* pass index for compositing and modifiers */
prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, nullptr, "pass_index");

View File

@ -2628,6 +2628,25 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
"Shade for bones corresponding to a locked weight group during painting");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
/* Time specific. */
prop = RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, nullptr, "cframe");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Current Frame", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "before_current_frame", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(
prop, "Before Current Frame", "The color for data that is from a frame before the current");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "after_current_frame", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(
prop, "After Current Frame", "The color for data that is from a frame after the current");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
/* misc */
prop = RNA_def_property(srna, "bundle_solid", PROP_FLOAT, PROP_COLOR_GAMMA);
@ -2662,12 +2681,6 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Transform", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, nullptr, "cframe");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Current Frame", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
rna_def_userdef_theme_spaces_paint_curves(srna);
prop = RNA_def_property(srna, "outline_width", PROP_INT, PROP_PIXEL);