From 77b66a96663c8e995160cc07287ccfea0e1a2b9b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Jan 2019 15:00:03 +1100 Subject: DRW: support clipping for empty object --- source/blender/gpu/shaders/gpu_shader_instance_camera_vert.glsl | 2 +- .../gpu_shader_instance_variying_size_variying_color_vert.glsl | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'source/blender/gpu/shaders') diff --git a/source/blender/gpu/shaders/gpu_shader_instance_camera_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_camera_vert.glsl index 07328385838..9a7815cc9d7 100644 --- a/source/blender/gpu/shaders/gpu_shader_instance_camera_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_instance_camera_vert.glsl @@ -52,6 +52,6 @@ void main() finalColor = vec4(color, 1.0); #ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance((ModelMatrix * InstanceModelMatrix * vec4(pPos, 1.0)).xyz); + world_clip_planes_calc_clip_distance((ModelMatrix * InstanceModelMatrix * vec4(pPos, 1.0)).xyz); #endif } diff --git a/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl index 0d0413fef94..fed00389fc1 100644 --- a/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl @@ -1,5 +1,6 @@ uniform mat4 ViewProjectionMatrix; +uniform mat4 ModelMatrix; /* ---- Instantiated Attribs ---- */ in vec3 pos; @@ -17,6 +18,12 @@ flat out vec4 finalColor; void main() { - gl_Position = ViewProjectionMatrix * InstanceModelMatrix * vec4(pos * size, 1.0); finalColor = color; + + vec4 pos_4d = vec4(pos * size, 1.0); + gl_Position = ViewProjectionMatrix * InstanceModelMatrix * pos_4d; + +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_calc_clip_distance((ModelMatrix * InstanceModelMatrix * pos_4d).xyz); +#endif } -- cgit v1.2.3