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-07 16:10:11 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-05-07 18:00:10 +0300
commit8ab3697e2107b955e188f4dec9d264df98e23d97 (patch)
tree7a4ebd8371a6d696b80b0515cb537e04bca03035 /source/blender/draw
parent2f76e95b96fc87a8ec598c5f8a9242bc220ad9c2 (diff)
Armature: Add new Transparent Bone overlay option.
This is half the replacement of the old wireframe mode. It's not doing any XRay drawing at the moment.
Diffstat (limited to 'source/blender/draw')
-rw-r--r--source/blender/draw/intern/draw_armature.c2
-rw-r--r--source/blender/draw/modes/edit_armature_mode.c16
-rw-r--r--source/blender/draw/modes/object_mode.c2
-rw-r--r--source/blender/draw/modes/pose_mode.c16
-rw-r--r--source/blender/draw/modes/shaders/armature_shape_solid_frag.glsl2
-rw-r--r--source/blender/draw/modes/shaders/armature_sphere_solid_frag.glsl3
6 files changed, 33 insertions, 8 deletions
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index 9c05f3165df..1a2ff70624b 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -1028,7 +1028,7 @@ static void draw_axes(EditBone *eBone, bPoseChannel *pchan)
const float *col = (g_theme.const_color) ? g_theme.const_color :
(BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? g_theme.text_hi_color : g_theme.text_color;
copy_v4_v4(final_col, col);
- final_col[3] = (g_theme.const_color) ? 1.0 : 0.4; /* Mix with axes color. */
+ final_col[3] = (g_theme.const_color) ? 1.0 : (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? 0.3 : 0.8; /* Mix with axes color. */
drw_shgroup_bone_axes(BONE_VAR(eBone, pchan, disp_mat), final_col);
}
diff --git a/source/blender/draw/modes/edit_armature_mode.c b/source/blender/draw/modes/edit_armature_mode.c
index e744565558b..0288a027b7c 100644
--- a/source/blender/draw/modes/edit_armature_mode.c
+++ b/source/blender/draw/modes/edit_armature_mode.c
@@ -27,6 +27,7 @@
#include "DRW_render.h"
#include "DNA_armature_types.h"
+#include "DNA_view3d_types.h"
#include "draw_common.h"
@@ -76,7 +77,7 @@ static void EDIT_ARMATURE_cache_init(void *vedata)
{
/* Solid bones */
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK;
psl->bone_solid = DRW_pass_create("Bone Solid Pass", state);
}
@@ -137,13 +138,24 @@ static void EDIT_ARMATURE_draw_scene(void *vedata)
EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const bool transparent_bones = (draw_ctx->v3d->overlay.arm_flag & V3D_OVERLAY_ARM_TRANSP_BONES) != 0;
DRW_draw_pass(psl->bone_envelope);
+ if (transparent_bones) {
+ DRW_pass_state_add(psl->bone_solid, DRW_STATE_BLEND);
+ DRW_pass_state_remove(psl->bone_solid, DRW_STATE_WRITE_DEPTH);
+ DRW_draw_pass(psl->bone_solid);
+ }
+
MULTISAMPLE_SYNC_ENABLE(dfbl, dtxl)
+ if (!transparent_bones) {
+ DRW_draw_pass(psl->bone_solid);
+ }
+
DRW_draw_pass(psl->bone_outline);
- DRW_draw_pass(psl->bone_solid);
DRW_draw_pass(psl->bone_wire);
DRW_draw_pass(psl->relationship);
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 1cfc8e9403d..312928c57f6 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -987,7 +987,7 @@ static void OBJECT_cache_init(void *vedata)
{
/* Solid bones */
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK;
psl->bone_solid = DRW_pass_create("Bone Solid Pass", state);
psl->bone_outline = DRW_pass_create("Bone Outline Pass", state);
}
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index 18318046869..a7fc1da959b 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -25,6 +25,7 @@
#include "DRW_engine.h"
#include "DRW_render.h"
+#include "DNA_view3d_types.h"
/* If builtin shaders are needed */
#include "GPU_shader.h"
@@ -85,7 +86,7 @@ static void POSE_cache_init(void *vedata)
{
/* Solid bones */
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK;
psl->bone_solid = DRW_pass_create("Bone Solid Pass", state);
}
@@ -175,14 +176,25 @@ static void POSE_draw_scene(void *vedata)
POSE_PassList *psl = ((POSE_Data *)vedata)->psl;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const bool transparent_bones = (draw_ctx->v3d->overlay.arm_flag & V3D_OVERLAY_ARM_TRANSP_BONES) != 0;
DRW_draw_pass(psl->bone_envelope);
+ if (transparent_bones) {
+ DRW_pass_state_add(psl->bone_solid, DRW_STATE_BLEND);
+ DRW_pass_state_remove(psl->bone_solid, DRW_STATE_WRITE_DEPTH);
+ DRW_draw_pass(psl->bone_solid);
+ }
+
MULTISAMPLE_SYNC_ENABLE(dfbl, dtxl)
+ if (!transparent_bones) {
+ DRW_draw_pass(psl->bone_solid);
+ }
+
DRW_draw_pass(psl->bone_outline);
DRW_draw_pass(psl->bone_wire);
- DRW_draw_pass(psl->bone_solid);
DRW_draw_pass(psl->relationship);
MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl)
diff --git a/source/blender/draw/modes/shaders/armature_shape_solid_frag.glsl b/source/blender/draw/modes/shaders/armature_shape_solid_frag.glsl
index aa455a85cf0..248281f4e79 100644
--- a/source/blender/draw/modes/shaders/armature_shape_solid_frag.glsl
+++ b/source/blender/draw/modes/shaders/armature_shape_solid_frag.glsl
@@ -5,5 +5,5 @@ out vec4 fragColor;
void main()
{
- fragColor = finalColor;
+ fragColor = vec4(finalColor.rgb, 0.6); /* Hardcoded transparency factor. */
}
diff --git a/source/blender/draw/modes/shaders/armature_sphere_solid_frag.glsl b/source/blender/draw/modes/shaders/armature_sphere_solid_frag.glsl
index a431a048282..3c80f629d79 100644
--- a/source/blender/draw/modes/shaders/armature_sphere_solid_frag.glsl
+++ b/source/blender/draw/modes/shaders/armature_sphere_solid_frag.glsl
@@ -73,7 +73,8 @@ void main()
float dither = (0.5 + dot(vec2(ivec2(gl_FragCoord.xy) & ivec2(1)), vec2(1.0, 2.0))) * 0.25;
dither *= (1.0 / 255.0); /* Assume 8bit per color buffer. */
- fragColor = vec4(fragColor.rgb + dither, 1.0);
+ /* Hardcoded transparency factor. Less than shape to be less distractive. */
+ fragColor = vec4(fragColor.rgb + dither, 0.4);
t /= ray_len;
gl_FragDepth = get_depth_from_view_z(ray_dir_view.z * t + ray_ori_view.z);