Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-05-08 13:05:06 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-05-08 13:18:35 +0300
commit9a79178c2eb79e724077d38cd2dd964d0b6ca0ea (patch)
tree0af8bc089ad3b7b5f978d700af29503358d21890 /source/blender/draw/intern/draw_common.c
parentd8706f54074675f8af83471398d35def0b351484 (diff)
Armature: Add back Stick bone draw type.
The actual code is a bit convoluted but allows good and "pseudo efficient" drawing. (pseudo efficient because rendering instances with that amount of vertices is really inneficient. We should go full procedural but need to have bufferTexture implemented first) But drawing speed is not a bottleneck here and it's already a million time less crappy than the old (2.79) immediate mode method. Instead of drawing actual wires with different width we render a triangle fan batch (containing 3 fans: bone, head, tail) which is then oriented in screen space to the bone direction. We then interpolate a float value accross vertices giving us a nice blend factor to blend the colors and gives us really smooth interpolation inside the bone. The outside edge still being geometry will be antialiased by MSAA if enabled.
Diffstat (limited to 'source/blender/draw/intern/draw_common.c')
-rw-r--r--source/blender/draw/intern/draw_common.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index 2c606aa57d7..ba5e04df512 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -165,6 +165,8 @@ extern char datatoc_armature_shape_solid_vert_glsl[];
extern char datatoc_armature_shape_solid_frag_glsl[];
extern char datatoc_armature_shape_outline_vert_glsl[];
extern char datatoc_armature_shape_outline_geom_glsl[];
+extern char datatoc_armature_stick_vert_glsl[];
+extern char datatoc_armature_stick_frag_glsl[];
extern char datatoc_gpu_shader_flat_color_frag_glsl[];
extern char datatoc_object_mball_handles_vert_glsl[];
@@ -178,6 +180,7 @@ static struct {
struct GPUShader *bone_envelope_outline;
struct GPUShader *bone_sphere;
struct GPUShader *bone_sphere_outline;
+ struct GPUShader *bone_stick;
struct GPUShader *mball_handles;
} g_shaders = {NULL};
@@ -194,6 +197,7 @@ static struct {
struct Gwn_VertFormat *instance_distance_lines;
struct Gwn_VertFormat *instance_spot;
struct Gwn_VertFormat *instance_bone;
+ struct Gwn_VertFormat *instance_bone_stick;
struct Gwn_VertFormat *instance_bone_outline;
struct Gwn_VertFormat *instance_bone_envelope;
struct Gwn_VertFormat *instance_bone_envelope_distance;
@@ -638,6 +642,30 @@ DRWShadingGroup *shgroup_instance_bone_sphere_outline(DRWPass *pass)
return grp;
}
+DRWShadingGroup *shgroup_instance_bone_stick(DRWPass *pass)
+{
+ if (g_shaders.bone_stick == NULL) {
+ g_shaders.bone_stick = DRW_shader_create(
+ datatoc_armature_stick_vert_glsl, NULL,
+ datatoc_armature_stick_frag_glsl, NULL);
+ }
+
+ DRW_shgroup_instance_format(g_formats.instance_bone_stick, {
+ {"boneStart", DRW_ATTRIB_FLOAT, 3},
+ {"boneEnd" , DRW_ATTRIB_FLOAT, 3},
+ {"wireColor", DRW_ATTRIB_FLOAT, 4}, /* TODO port theses to uchar color */
+ {"boneColor", DRW_ATTRIB_FLOAT, 4},
+ {"headColor", DRW_ATTRIB_FLOAT, 4},
+ {"tailColor", DRW_ATTRIB_FLOAT, 4}
+ });
+
+ DRWShadingGroup *grp = DRW_shgroup_instance_create(g_shaders.bone_stick,
+ pass, DRW_cache_bone_stick_get(),
+ g_formats.instance_bone_stick);
+ DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
+
+ return grp;
+}
/* ******************************************** COLOR UTILS *********************************************** */