Overlay Engine: Armature: Use Wire AA on custom bone loose edges
This commit is contained in:
@@ -317,6 +317,7 @@ data_to_c_simple(engines/overlay/shaders/armature_shape_outline_geom.glsl SRC)
|
||||
data_to_c_simple(engines/overlay/shaders/armature_shape_outline_vert.glsl SRC)
|
||||
data_to_c_simple(engines/overlay/shaders/armature_shape_solid_frag.glsl SRC)
|
||||
data_to_c_simple(engines/overlay/shaders/armature_shape_solid_vert.glsl SRC)
|
||||
data_to_c_simple(engines/overlay/shaders/armature_shape_wire_vert.glsl SRC)
|
||||
data_to_c_simple(engines/overlay/shaders/armature_sphere_outline_vert.glsl SRC)
|
||||
data_to_c_simple(engines/overlay/shaders/armature_sphere_solid_frag.glsl SRC)
|
||||
data_to_c_simple(engines/overlay/shaders/armature_sphere_solid_vert.glsl SRC)
|
||||
|
||||
@@ -223,6 +223,11 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata)
|
||||
DRW_shgroup_uniform_block_persistent(grp, "globalsBlock", G_draw.block_ubo);
|
||||
cb->box_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_box_wire_get());
|
||||
cb->octa_outline = BUF_INSTANCE(grp, format, DRW_cache_bone_octahedral_wire_get());
|
||||
|
||||
sh = OVERLAY_shader_armature_shape_wire();
|
||||
cb->custom_wire = grp = DRW_shgroup_create(sh, armature_ps);
|
||||
DRW_shgroup_state_disable(grp, DRW_STATE_BLEND_ALPHA);
|
||||
DRW_shgroup_uniform_block_persistent(grp, "globalsBlock", G_draw.block_ubo);
|
||||
}
|
||||
{
|
||||
format = formats->instance_extra;
|
||||
@@ -2205,7 +2210,7 @@ static void armature_context_setup(ArmatureDrawContext *ctx,
|
||||
ctx->point_outline = cb->point_outline;
|
||||
ctx->custom_solid = (is_filled) ? cb->custom_solid : NULL;
|
||||
ctx->custom_outline = cb->custom_outline;
|
||||
ctx->custom_wire = cb->custom_solid; /* Use same shader. */
|
||||
ctx->custom_wire = cb->custom_wire;
|
||||
ctx->custom_shapes_ghash = cb->custom_shapes_ghash;
|
||||
ctx->transparent = pd->armature.transparent;
|
||||
ctx->show_relations = pd->armature.show_relations;
|
||||
|
||||
@@ -197,6 +197,7 @@ typedef struct OVERLAY_ArmatureCallBuffers {
|
||||
|
||||
DRWShadingGroup *custom_solid;
|
||||
DRWShadingGroup *custom_outline;
|
||||
DRWShadingGroup *custom_wire;
|
||||
GHash *custom_shapes_ghash;
|
||||
} OVERLAY_ArmatureCallBuffers;
|
||||
|
||||
@@ -520,6 +521,7 @@ GPUShader *OVERLAY_shader_antialiasing(void);
|
||||
GPUShader *OVERLAY_shader_armature_degrees_of_freedom(void);
|
||||
GPUShader *OVERLAY_shader_armature_envelope(bool use_outline);
|
||||
GPUShader *OVERLAY_shader_armature_shape(bool use_outline);
|
||||
GPUShader *OVERLAY_shader_armature_shape_wire(void);
|
||||
GPUShader *OVERLAY_shader_armature_sphere(bool use_outline);
|
||||
GPUShader *OVERLAY_shader_armature_stick(void);
|
||||
GPUShader *OVERLAY_shader_armature_wire(void);
|
||||
|
||||
@@ -39,6 +39,7 @@ extern char datatoc_armature_shape_outline_geom_glsl[];
|
||||
extern char datatoc_armature_shape_outline_vert_glsl[];
|
||||
extern char datatoc_armature_shape_solid_frag_glsl[];
|
||||
extern char datatoc_armature_shape_solid_vert_glsl[];
|
||||
extern char datatoc_armature_shape_wire_vert_glsl[];
|
||||
extern char datatoc_armature_sphere_outline_vert_glsl[];
|
||||
extern char datatoc_armature_sphere_solid_frag_glsl[];
|
||||
extern char datatoc_armature_sphere_solid_vert_glsl[];
|
||||
@@ -123,6 +124,7 @@ typedef struct OVERLAY_Shaders {
|
||||
GPUShader *armature_envelope_solid;
|
||||
GPUShader *armature_shape_outline;
|
||||
GPUShader *armature_shape_solid;
|
||||
GPUShader *armature_shape_wire;
|
||||
GPUShader *armature_sphere_outline;
|
||||
GPUShader *armature_sphere_solid;
|
||||
GPUShader *armature_stick;
|
||||
@@ -353,6 +355,26 @@ GPUShader *OVERLAY_shader_armature_shape(bool use_outline)
|
||||
return use_outline ? sh_data->armature_shape_outline : sh_data->armature_shape_solid;
|
||||
}
|
||||
|
||||
GPUShader *OVERLAY_shader_armature_shape_wire(void)
|
||||
{
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg];
|
||||
OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
|
||||
if (!sh_data->armature_shape_wire) {
|
||||
sh_data->armature_shape_wire = GPU_shader_create_from_arrays({
|
||||
.vert = (const char *[]){sh_cfg->lib,
|
||||
datatoc_common_globals_lib_glsl,
|
||||
datatoc_common_view_lib_glsl,
|
||||
datatoc_armature_shape_wire_vert_glsl,
|
||||
NULL},
|
||||
.frag =
|
||||
(const char *[]){datatoc_common_view_lib_glsl, datatoc_armature_wire_frag_glsl, NULL},
|
||||
.defs = (const char *[]){sh_cfg->def, NULL},
|
||||
});
|
||||
}
|
||||
return sh_data->armature_shape_wire;
|
||||
}
|
||||
|
||||
GPUShader *OVERLAY_shader_armature_envelope(bool use_outline)
|
||||
{
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
/* ---- Instantiated Attrs ---- */
|
||||
in vec3 pos;
|
||||
in vec3 nor;
|
||||
|
||||
/* ---- Per instance Attrs ---- */
|
||||
in mat4 inst_obmat;
|
||||
|
||||
out vec4 finalColor;
|
||||
flat out vec2 edgeStart;
|
||||
noperspective out vec2 edgePos;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 bone_color, state_color;
|
||||
mat4 model_mat = extract_matrix_packed_data(inst_obmat, state_color, bone_color);
|
||||
|
||||
vec3 world_pos = (model_mat * vec4(pos, 1.0)).xyz;
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
|
||||
finalColor.rgb = mix(state_color.rgb, bone_color.rgb, 0.5);
|
||||
finalColor.a = 1.0;
|
||||
|
||||
edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy;
|
||||
|
||||
#ifdef USE_WORLD_CLIP_PLANES
|
||||
world_clip_planes_calc_clip_distance(world_pos);
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user