From 6aebb5a4d5f5c0866263b8507dbed460f60ba64f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Mar 2019 17:37:08 +1100 Subject: DRW: support clipping for relationship lines --- source/blender/gpu/intern/gpu_shader.c | 3 ++- source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl | 8 ++++++++ .../shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl | 10 +++++++++- 3 files changed, 19 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 55b696e5ba2..be82d3d5d99 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -1242,7 +1242,8 @@ GPUShader *GPU_shader_get_builtin_shader_with_config( GPU_SHADER_3D_FLAT_SELECT_ID, GPU_SHADER_3D_UNIFORM_SELECT_ID) || ELEM(shader, - GPU_SHADER_3D_FLAT_COLOR)); + GPU_SHADER_3D_FLAT_COLOR, + GPU_SHADER_3D_LINE_DASHED_UNIFORM_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_2D_line_dashed_geom.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl index 8fa19f94b39..1e5a75c37b8 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl @@ -30,6 +30,10 @@ void main() gl_Position = v1; color_geom = color_vert[0]; distance_along_line = 0.0f; + +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_set_clip_distance(gl_in[0].gl_ClipDistance); +#endif EmitVertex(); gl_Position = v2; @@ -47,6 +51,10 @@ void main() distance_along_line = distance(p1, p2); } + +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_set_clip_distance(gl_in[1].gl_ClipDistance); +#endif EmitVertex(); EndPrimitive(); diff --git a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl index 2fe08896585..791f634c6cd 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl @@ -8,6 +8,10 @@ uniform mat4 ModelViewProjectionMatrix; +#ifdef USE_WORLD_CLIP_PLANES +uniform mat4 ModelMatrix; +#endif + uniform vec4 color; in vec3 pos; @@ -16,6 +20,10 @@ out vec4 color_vert; void main() { - gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); + vec4 pos_4d = vec4(pos, 1.0); + gl_Position = ModelViewProjectionMatrix * pos_4d; color_vert = color; +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_calc_clip_distance((ModelMatrix * pos_4d).xyz); +#endif } -- cgit v1.2.3