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-04-29 20:39:44 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-05-02 21:49:38 +0300
commit01cec3e0c52184f288a9af28b67d09965ebb0b03 (patch)
treedcf6256b52104d14ac16a3b1f242c270a88dbfc2 /source/blender/draw/intern/draw_common.c
parent18071f4e0eee407f9a05a0e56f3f46b715d82b09 (diff)
Armature: Envelope Bones: Change drawing method.
We now use a more pleasant and efficient way to display enveloppe bones and their radius. For this we use a capsule geometry that is displaced (in the vertex shader) to a signed distance field that represents the bone shape. The bone distance radius are now drawn in 3D using a "pseudo-fresnel" effect. This gives a better understanding of what is inside the radius of influence. When capsules are not needed, we switch to default raytraced points. The capsules are not distorded by the bone's matrix (same as their actual influence radius) and are correctly displayed even with complex scaled parents hierarchy.
Diffstat (limited to 'source/blender/draw/intern/draw_common.c')
-rw-r--r--source/blender/draw/intern/draw_common.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index 6d684b1c9fb..8697d4c814e 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -158,6 +158,8 @@ void DRW_globals_update(void)
extern char datatoc_armature_sphere_vert_glsl[];
extern char datatoc_armature_sphere_frag_glsl[];
+extern char datatoc_armature_envelope_vert_glsl[];
+extern char datatoc_armature_envelope_frag_glsl[];
extern char datatoc_armature_sphere_outline_vert_glsl[];
extern char datatoc_armature_shape_outline_vert_glsl[];
extern char datatoc_armature_shape_outline_geom_glsl[];
@@ -165,6 +167,8 @@ extern char datatoc_gpu_shader_flat_color_frag_glsl[];
static struct {
struct GPUShader *shape_outline;
+ struct GPUShader *bone_envelope;
+ struct GPUShader *bone_envelope_outline;
struct GPUShader *bone_sphere;
struct GPUShader *bone_sphere_outline;
} g_armature_shaders = {NULL};
@@ -438,20 +442,24 @@ DRWShadingGroup *shgroup_instance_bone_envelope_wire(DRWPass *pass, struct Gwn_B
return grp;
}
-DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass, struct Gwn_Batch *geom)
+DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass)
{
- static float light[3] = {0.0f, 0.0f, 1.0f};
- GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID);
+ if (g_armature_shaders.bone_envelope == NULL) {
+ g_armature_shaders.bone_envelope = DRW_shader_create(
+ datatoc_armature_envelope_vert_glsl, NULL,
+ datatoc_armature_envelope_frag_glsl, NULL);
+ }
DRW_shgroup_instance_format(g_formats.instance_bone_envelope_solid, {
- {"InstanceModelMatrix" , DRW_ATTRIB_FLOAT, 16},
+ {"headSphere" , DRW_ATTRIB_FLOAT, 4},
+ {"tailSphere" , DRW_ATTRIB_FLOAT, 4},
{"color" , DRW_ATTRIB_FLOAT, 4},
- {"radius_head" , DRW_ATTRIB_FLOAT, 1},
- {"radius_tail" , DRW_ATTRIB_FLOAT, 1}
+ {"xAxis" , DRW_ATTRIB_FLOAT, 3}
});
- DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom, g_formats.instance_bone_envelope_solid);
- DRW_shgroup_uniform_vec3(grp, "light", light, 1);
+ DRWShadingGroup *grp = DRW_shgroup_instance_create(g_armature_shaders.bone_envelope,
+ pass, DRW_cache_bone_envelope_solid_get(),
+ g_formats.instance_bone_envelope_solid);
return grp;
}