Armature: Make bone outlines thickness variable.
This commit is contained in:
parent
eec3fc1273
commit
3b075d0c8d
|
@ -187,7 +187,9 @@ static struct {
|
|||
struct Gwn_VertFormat *instance_camera;
|
||||
struct Gwn_VertFormat *instance_distance_lines;
|
||||
struct Gwn_VertFormat *instance_spot;
|
||||
struct Gwn_VertFormat *instance_bone_outline;
|
||||
struct Gwn_VertFormat *instance_bone_envelope;
|
||||
struct Gwn_VertFormat *instance_bone_envelope_outline;
|
||||
struct Gwn_VertFormat *instance_mball_handles;
|
||||
} g_formats = {NULL};
|
||||
|
||||
|
@ -435,16 +437,16 @@ DRWShadingGroup *shgroup_instance_bone_envelope_outline(DRWPass *pass)
|
|||
datatoc_gpu_shader_flat_color_frag_glsl, NULL);
|
||||
}
|
||||
|
||||
DRW_shgroup_instance_format(g_formats.instance_bone_envelope, {
|
||||
DRW_shgroup_instance_format(g_formats.instance_bone_envelope_outline, {
|
||||
{"headSphere" , DRW_ATTRIB_FLOAT, 4},
|
||||
{"tailSphere" , DRW_ATTRIB_FLOAT, 4},
|
||||
{"color" , DRW_ATTRIB_FLOAT, 4},
|
||||
{"outlineColorSize" , DRW_ATTRIB_FLOAT, 4},
|
||||
{"xAxis" , DRW_ATTRIB_FLOAT, 3}
|
||||
});
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_instance_create(g_shaders.bone_envelope_outline,
|
||||
pass, DRW_cache_bone_envelope_outline_get(),
|
||||
g_formats.instance_bone_envelope);
|
||||
g_formats.instance_bone_envelope_outline);
|
||||
DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
|
||||
|
||||
return grp;
|
||||
|
@ -527,14 +529,13 @@ DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct Gwn_B
|
|||
NULL);
|
||||
}
|
||||
|
||||
/* TODO own format? */
|
||||
DRW_shgroup_instance_format(g_formats.instance_color, {
|
||||
DRW_shgroup_instance_format(g_formats.instance_bone_outline, {
|
||||
{"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
|
||||
{"color" , DRW_ATTRIB_FLOAT, 4}
|
||||
{"outlineColorSize" , DRW_ATTRIB_FLOAT, 4}
|
||||
});
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_instance_create(g_shaders.shape_outline,
|
||||
pass, geom, g_formats.instance_color);
|
||||
pass, geom, g_formats.instance_bone_outline);
|
||||
DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
|
||||
|
||||
return grp;
|
||||
|
@ -568,15 +569,14 @@ DRWShadingGroup *shgroup_instance_bone_sphere_outline(DRWPass *pass)
|
|||
datatoc_gpu_shader_flat_color_frag_glsl, NULL);
|
||||
}
|
||||
|
||||
/* TODO own format? */
|
||||
DRW_shgroup_instance_format(g_formats.instance_color, {
|
||||
DRW_shgroup_instance_format(g_formats.instance_bone_outline, {
|
||||
{"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
|
||||
{"color" , DRW_ATTRIB_FLOAT, 4}
|
||||
{"outlineColorSize" , DRW_ATTRIB_FLOAT, 4}
|
||||
});
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_instance_create(g_shaders.bone_sphere_outline,
|
||||
pass, DRW_cache_bone_point_wire_outline_get(),
|
||||
g_formats.instance_color);
|
||||
g_formats.instance_bone_outline);
|
||||
DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
|
||||
|
||||
return grp;
|
||||
|
|
|
@ -16,7 +16,7 @@ in vec2 pos2;
|
|||
/* Assumed to be in world coordinate already. */
|
||||
in vec4 headSphere;
|
||||
in vec4 tailSphere;
|
||||
in vec4 color;
|
||||
in vec4 outlineColorSize;
|
||||
in vec3 xAxis;
|
||||
|
||||
flat out vec4 finalColor;
|
||||
|
@ -145,12 +145,12 @@ void main()
|
|||
vec2 edge_dir = compute_dir(ss0, ss1, ss2);
|
||||
|
||||
bool outer = ((gl_VertexID & 1) == 1);
|
||||
vec2 t = lineThickness / viewportSize;
|
||||
vec2 t = outlineColorSize.w * (lineThickness / viewportSize);
|
||||
t *= pres_fac;
|
||||
t = (outer) ? t : vec2(0.0);
|
||||
|
||||
gl_Position = p1;
|
||||
gl_Position.xy += t * edge_dir;
|
||||
|
||||
finalColor = color;
|
||||
finalColor = vec4(outlineColorSize.rgb, 1.0);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ in float vZ[];
|
|||
in float vFacing[];
|
||||
in vec2 ssPos[];
|
||||
in vec2 ssNor[];
|
||||
in vec4 vCol[];
|
||||
in vec4 vColSize[];
|
||||
|
||||
flat out vec4 finalColor;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
|
@ -53,9 +53,9 @@ void emit_corner(const int e, vec2 thick, bool is_persp)
|
|||
|
||||
void main(void)
|
||||
{
|
||||
finalColor = vCol[0];
|
||||
finalColor = vec4(vColSize[0].rgb, 1.0);
|
||||
|
||||
vec2 thick = lineThickness / viewportSize;
|
||||
vec2 thick = vColSize[0].w * (lineThickness / viewportSize);
|
||||
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
|
||||
|
||||
const ivec3 edges = ivec3(0, 2, 4);
|
||||
|
|
|
@ -12,14 +12,14 @@ in vec3 snor;
|
|||
|
||||
/* ---- Per instance Attribs ---- */
|
||||
in mat4 InstanceModelMatrix;
|
||||
in vec4 color;
|
||||
in vec4 outlineColorSize;
|
||||
|
||||
out vec4 pPos;
|
||||
out float vZ;
|
||||
out float vFacing;
|
||||
out vec2 ssPos;
|
||||
out vec2 ssNor;
|
||||
out vec4 vCol;
|
||||
out vec4 vColSize;
|
||||
|
||||
/* project to screen space */
|
||||
vec2 proj(vec4 pos)
|
||||
|
@ -49,5 +49,5 @@ void main()
|
|||
|
||||
ssPos = proj(pPos);
|
||||
|
||||
vCol = color;
|
||||
vColSize = outlineColorSize;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ in vec2 pos1;
|
|||
|
||||
/* ---- Per instance Attribs ---- */
|
||||
in mat4 InstanceModelMatrix;
|
||||
in vec4 color;
|
||||
in vec4 outlineColorSize;
|
||||
|
||||
flat out vec4 finalColor;
|
||||
|
||||
|
@ -91,12 +91,12 @@ void main()
|
|||
|
||||
bool outer = ((gl_VertexID & 1) == 1);
|
||||
|
||||
vec2 t = lineThickness / viewportSize;
|
||||
vec2 t = outlineColorSize.w * (lineThickness / viewportSize);
|
||||
t *= (is_persp) ? abs(V.z) : 1.0;
|
||||
t = (outer) ? t : vec2(0.0);
|
||||
|
||||
gl_Position = p0;
|
||||
gl_Position.xy += t * edge_dir;
|
||||
|
||||
finalColor = color;
|
||||
finalColor = vec4(outlineColorSize.rgb, 1.0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue