WIP: Onion Skinning Prototype #107641
|
@ -739,6 +739,7 @@ class RENDER_PT_onion_skins(RenderButtonsPanel, Panel):
|
||||||
col.prop(scene, "os_relative_left")
|
col.prop(scene, "os_relative_left")
|
||||||
col.prop(scene, "os_relative_right")
|
col.prop(scene, "os_relative_right")
|
||||||
col.prop(scene, "onion_skin_alpha")
|
col.prop(scene, "onion_skin_alpha")
|
||||||
|
col.prop(scene, "onion_skin_draw_modes")
|
||||||
|
|
||||||
|
|
||||||
class RENDER_PT_opengl_sampling(RenderButtonsPanel, Panel):
|
class RENDER_PT_opengl_sampling(RenderButtonsPanel, Panel):
|
||||||
|
|
|
@ -11,10 +11,14 @@ void OVERLAY_onion_skin_init(OVERLAY_Data *vedata)
|
||||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA;
|
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA;
|
||||||
DRW_PASS_CREATE(psl->onion_skin_ps, state | pd->clipping_state);
|
DRW_PASS_CREATE(psl->onion_skin_ps, state | pd->clipping_state);
|
||||||
|
|
||||||
GPUShader *shader = OVERLAY_shader_onion_skin_mesh();
|
|
||||||
DRWShadingGroup *grp;
|
DRWShadingGroup *grp;
|
||||||
pd->onion_skin_grp = grp = DRW_shgroup_create(shader, psl->onion_skin_ps);
|
|
||||||
|
|
||||||
|
GPUShader *shader = OVERLAY_shader_onion_skin_mesh();
|
||||||
|
pd->onion_skin_grp = grp = DRW_shgroup_create(shader, psl->onion_skin_ps);
|
||||||
|
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
|
||||||
|
|
||||||
|
GPUShader *shader_outline = OVERLAY_shader_onion_skin_outline();
|
||||||
|
pd->onion_skin_outline_grp = grp = DRW_shgroup_create(shader_outline, psl->onion_skin_ps);
|
||||||
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
|
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,14 +36,20 @@ static bool str_equals(const char *__restrict str, const char *__restrict start)
|
||||||
void OVERLAY_onion_skin_populate(OVERLAY_Data *vedata, Object *ob)
|
void OVERLAY_onion_skin_populate(OVERLAY_Data *vedata, Object *ob)
|
||||||
{
|
{
|
||||||
OVERLAY_PrivateData *pd = vedata->stl->pd;
|
OVERLAY_PrivateData *pd = vedata->stl->pd;
|
||||||
DRWShadingGroup *grp = pd->onion_skin_grp;
|
|
||||||
|
|
||||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||||
|
|
||||||
Scene *scene = draw_ctx->scene;
|
Scene *scene = draw_ctx->scene;
|
||||||
const float current_frame = BKE_scene_ctime_get(scene);
|
const float current_frame = BKE_scene_ctime_get(scene);
|
||||||
|
|
||||||
DRW_shgroup_uniform_float_copy(grp, "alpha", draw_ctx->scene->onion_skin_cache.alpha);
|
DRWShadingGroup *grp = nullptr;
|
||||||
|
if (scene->onion_skin_cache.draw_method == ONION_SKIN_DRAW_SOLID) {
|
||||||
|
grp = pd->onion_skin_grp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
grp = pd->onion_skin_outline_grp;
|
||||||
|
}
|
||||||
|
DRW_shgroup_uniform_float_copy(grp, "alpha", scene->onion_skin_cache.alpha);
|
||||||
|
|
||||||
LISTBASE_FOREACH (OnionSkinMeshLink *, mesh_link, &scene->onion_skin_cache.objects) {
|
LISTBASE_FOREACH (OnionSkinMeshLink *, mesh_link, &scene->onion_skin_cache.objects) {
|
||||||
if (!str_equals(ob->id.name, mesh_link->object->id.name)) {
|
if (!str_equals(ob->id.name, mesh_link->object->id.name)) {
|
||||||
|
|
|
@ -281,6 +281,7 @@ typedef struct OVERLAY_PrivateData {
|
||||||
DRWShadingGroup *motion_path_lines_grp;
|
DRWShadingGroup *motion_path_lines_grp;
|
||||||
DRWShadingGroup *motion_path_points_grp;
|
DRWShadingGroup *motion_path_points_grp;
|
||||||
DRWShadingGroup *onion_skin_grp;
|
DRWShadingGroup *onion_skin_grp;
|
||||||
|
DRWShadingGroup *onion_skin_outline_grp;
|
||||||
DRWShadingGroup *outlines_grp;
|
DRWShadingGroup *outlines_grp;
|
||||||
DRWShadingGroup *outlines_curves_grp;
|
DRWShadingGroup *outlines_curves_grp;
|
||||||
DRWShadingGroup *outlines_ptcloud_grp;
|
DRWShadingGroup *outlines_ptcloud_grp;
|
||||||
|
@ -777,6 +778,7 @@ GPUShader *OVERLAY_shader_image(void);
|
||||||
GPUShader *OVERLAY_shader_motion_path_line(void);
|
GPUShader *OVERLAY_shader_motion_path_line(void);
|
||||||
GPUShader *OVERLAY_shader_motion_path_vert(void);
|
GPUShader *OVERLAY_shader_motion_path_vert(void);
|
||||||
GPUShader *OVERLAY_shader_onion_skin_mesh(void);
|
GPUShader *OVERLAY_shader_onion_skin_mesh(void);
|
||||||
|
GPUShader *OVERLAY_shader_onion_skin_outline(void);
|
||||||
GPUShader *OVERLAY_shader_uniform_color(void);
|
GPUShader *OVERLAY_shader_uniform_color(void);
|
||||||
GPUShader *OVERLAY_shader_uniform_color_pointcloud(void);
|
GPUShader *OVERLAY_shader_uniform_color_pointcloud(void);
|
||||||
GPUShader *OVERLAY_shader_outline_prepass(bool use_wire);
|
GPUShader *OVERLAY_shader_outline_prepass(bool use_wire);
|
||||||
|
|
|
@ -79,6 +79,7 @@ struct OVERLAY_Shaders {
|
||||||
GPUShader *motion_path_line;
|
GPUShader *motion_path_line;
|
||||||
GPUShader *motion_path_vert;
|
GPUShader *motion_path_vert;
|
||||||
GPUShader *onion_skin_mesh;
|
GPUShader *onion_skin_mesh;
|
||||||
|
GPUShader *onion_skin_outline;
|
||||||
GPUShader *outline_prepass;
|
GPUShader *outline_prepass;
|
||||||
GPUShader *outline_prepass_curves;
|
GPUShader *outline_prepass_curves;
|
||||||
GPUShader *outline_prepass_gpencil;
|
GPUShader *outline_prepass_gpencil;
|
||||||
|
@ -696,6 +697,16 @@ GPUShader *OVERLAY_shader_onion_skin_mesh(void)
|
||||||
return sh_data->onion_skin_mesh;
|
return sh_data->onion_skin_mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPUShader *OVERLAY_shader_onion_skin_outline(void)
|
||||||
|
{
|
||||||
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||||
|
OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
|
||||||
|
if (!sh_data->onion_skin_outline) {
|
||||||
|
sh_data->onion_skin_outline = GPU_shader_create_from_info_name("overlay_outline_detect");
|
||||||
|
}
|
||||||
|
return sh_data->onion_skin_outline;
|
||||||
|
}
|
||||||
|
|
||||||
GPUShader *OVERLAY_shader_outline_prepass(bool use_wire)
|
GPUShader *OVERLAY_shader_outline_prepass(bool use_wire)
|
||||||
{
|
{
|
||||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||||
|
|
|
@ -260,6 +260,7 @@ GPU_SHADER_CREATE_INFO(overlay_onion_skin_mesh)
|
||||||
.vertex_out(onion_skin_iface)
|
.vertex_out(onion_skin_iface)
|
||||||
.push_constant(Type::VEC3, "color")
|
.push_constant(Type::VEC3, "color")
|
||||||
.push_constant(Type::FLOAT, "alpha")
|
.push_constant(Type::FLOAT, "alpha")
|
||||||
|
.push_constant(Type::INT, "draw_method")
|
||||||
.fragment_out(0, Type::VEC4, "fragColor")
|
.fragment_out(0, Type::VEC4, "fragColor")
|
||||||
.fragment_source("overlay_onion_skin_mesh_frag.glsl")
|
.fragment_source("overlay_onion_skin_mesh_frag.glsl")
|
||||||
.vertex_source("overlay_onion_skin_mesh_vert.glsl")
|
.vertex_source("overlay_onion_skin_mesh_vert.glsl")
|
||||||
|
|
|
@ -1865,12 +1865,17 @@ typedef struct OnionSkinMeshLink {
|
||||||
char _pad[4];
|
char _pad[4];
|
||||||
} OnionSkinMeshLink;
|
} OnionSkinMeshLink;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ONION_SKIN_DRAW_SOLID = 0,
|
||||||
|
ONION_SKIN_DRAW_OUTLINE = 1,
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct SceneOnionSkin {
|
typedef struct SceneOnionSkin {
|
||||||
float color_left[3];
|
float color_left[3];
|
||||||
float color_right[3];
|
float color_right[3];
|
||||||
float alpha;
|
float alpha;
|
||||||
int relative_left, relative_right;
|
int relative_left, relative_right;
|
||||||
char _pad[4];
|
int draw_method;
|
||||||
ListBase objects /* OnionSkinMeshLink */;
|
ListBase objects /* OnionSkinMeshLink */;
|
||||||
} SceneOnionSkin;
|
} SceneOnionSkin;
|
||||||
|
|
||||||
|
|
|
@ -671,6 +671,12 @@ static const EnumPropertyItem plane_orientation_items[] = {
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, NULL, 0, NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const EnumPropertyItem onion_skin_draw_modes[] = {
|
||||||
|
{ONION_SKIN_DRAW_SOLID, "SOLID", 0, "Solid", "Draw solid shape"},
|
||||||
|
{ONION_SKIN_DRAW_OUTLINE, "OUTLINE", 0, "Outline", "Draw outline"},
|
||||||
|
{0, NULL, 0, NULL, NULL},
|
||||||
|
};
|
||||||
|
|
||||||
static const EnumPropertyItem snap_to_items[] = {
|
static const EnumPropertyItem snap_to_items[] = {
|
||||||
{SCE_SNAP_MODE_GEOM, "GEOMETRY", 0, "Geometry", "Snap to all geometry"},
|
{SCE_SNAP_MODE_GEOM, "GEOMETRY", 0, "Geometry", "Snap to all geometry"},
|
||||||
{SCE_SNAP_MODE_NONE, "DEFAULT", 0, "Default", "Use the current snap settings"},
|
{SCE_SNAP_MODE_NONE, "DEFAULT", 0, "Default", "Use the current snap settings"},
|
||||||
|
@ -8478,6 +8484,12 @@ void RNA_def_scene(BlenderRNA *brna)
|
||||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
|
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "onion_skin_draw_modes", PROP_ENUM, PROP_NONE);
|
||||||
|
RNA_def_property_enum_sdna(prop, NULL, "onion_skin_cache.draw_method");
|
||||||
|
RNA_def_property_enum_items(prop, onion_skin_draw_modes);
|
||||||
|
RNA_def_property_enum_default(prop, ONION_SKIN_DRAW_SOLID);
|
||||||
|
RNA_def_property_ui_text(prop, "Onion Skin Draw Modes", "How to draw os's");
|
||||||
|
|
||||||
/* Nestled Data. */
|
/* Nestled Data. */
|
||||||
/* *** Non-Animated *** */
|
/* *** Non-Animated *** */
|
||||||
RNA_define_animate_sdna(false);
|
RNA_define_animate_sdna(false);
|
||||||
|
|
Loading…
Reference in New Issue