From 813800f143b90480f563d1e1dd6fbb9acd3e5f87 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 8 Feb 2019 22:51:37 +1100 Subject: DRW: support clipping for stick & wire bones --- source/blender/gpu/intern/gpu_shader.c | 4 +++- source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 099431fa269..8bc53a71b5a 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -1220,7 +1220,9 @@ GPUShader *GPU_shader_get_builtin_shader_with_config( GPU_SHADER_DISTANCE_LINES, GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR, GPU_SHADER_3D_FLAT_SELECT_ID, - GPU_SHADER_3D_UNIFORM_SELECT_ID)); + GPU_SHADER_3D_UNIFORM_SELECT_ID) || + ELEM(shader, + GPU_SHADER_3D_FLAT_COLOR)); const char *world_clip_lib = datatoc_gpu_shader_cfg_world_clip_lib_glsl; const char *world_clip_def = "#define USE_WORLD_CLIP_PLANES\n"; /* In rare cases geometry shaders calculate clipping themselves. */ diff --git a/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl index 7db7e28d8e6..d4e6f697936 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl @@ -1,5 +1,8 @@ uniform mat4 ModelViewProjectionMatrix; +#ifdef USE_WORLD_CLIP_PLANES +uniform mat4 ModelMatrix; +#endif in vec3 pos; #if defined(USE_COLOR_U32) @@ -12,7 +15,8 @@ flat out vec4 finalColor; void main() { - gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); + vec4 pos_4d = vec4(pos, 1.0); + gl_Position = ModelViewProjectionMatrix * pos_4d; #if defined(USE_COLOR_U32) finalColor = vec4( @@ -23,4 +27,8 @@ void main() #else finalColor = color; #endif + +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_calc_clip_distance((ModelMatrix * pos_4d).xyz); +#endif } -- cgit v1.2.3