diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-01-29 11:57:35 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-01-29 12:27:28 +0300 |
commit | 851d58b34f11f73403729d595116a1b189093821 (patch) | |
tree | d625e9c374953cc2630e4292aae3ac62df3f6894 /source/blender/gpu | |
parent | 68ae1f4958e24906992a3207726c0031de9524b5 (diff) |
DRW: support clipping for all lamp types
Diffstat (limited to 'source/blender/gpu')
6 files changed, 44 insertions, 4 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl b/source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl index f16fa21b342..29bdd03f7e3 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl @@ -8,9 +8,18 @@ layout(line_strip, max_vertices = 2) out; void main() { vec3 vert = gl_in[0].gl_Position.xyz; + gl_Position = ViewProjectionMatrix * vec4(vert.xyz, 1.0); +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_set_clip_distance(gl_in[0].gl_ClipDistance); +#endif EmitVertex(); + gl_Position = ViewProjectionMatrix * vec4(vert.xy, 0.0, 1.0); +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_calc_clip_distance(vec3(vert.xy, 0.0)); +#endif EmitVertex(); + EndPrimitive(); } diff --git a/source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl index 55f410eb25d..b08d87cdfa6 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl @@ -6,6 +6,11 @@ in vec3 pos; void main() { - gl_Position = ViewProjectionMatrix * vec4(pos.xy, 0.0, 1.0); + vec4 pos_4d = vec4(pos.xy, 0.0, 1.0); + gl_Position = ViewProjectionMatrix * pos_4d; gl_PointSize = 2.0; + +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_calc_clip_distance(pos_4d.xyz); +#endif } diff --git a/source/blender/gpu/shaders/gpu_shader_3D_passthrough_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_passthrough_vert.glsl index 60793bf56b6..4196dbbad02 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_passthrough_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_passthrough_vert.glsl @@ -1,8 +1,16 @@ +#ifdef USE_WORLD_CLIP_PLANES +uniform mat4 ModelMatrix; +#endif /* Does Nothing */ in vec3 pos; void main() { - gl_Position = vec4(pos, 1.0); + vec4 pos_4d = vec4(pos, 1.0); + gl_Position = pos_4d; + +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_calc_clip_distance((ModelMatrix * pos_4d).xyz); +#endif } diff --git a/source/blender/gpu/shaders/gpu_shader_instance_distance_line_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_distance_line_vert.glsl index 432b6cac049..2097b900666 100644 --- a/source/blender/gpu/shaders/gpu_shader_instance_distance_line_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_instance_distance_line_vert.glsl @@ -18,8 +18,13 @@ void main() { float len = end - start; vec3 sta = vec3(0.0, 0.0, -start); + vec4 pos_4d = vec4(pos * -len + sta, 1.0); - gl_Position = ViewProjectionMatrix * InstanceModelMatrix * vec4(pos * -len + sta, 1.0); + gl_Position = ViewProjectionMatrix * InstanceModelMatrix * pos_4d; gl_PointSize = size; finalColor = vec4(color, 1.0); + +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_calc_clip_distance((InstanceModelMatrix * pos_4d).xyz); +#endif } diff --git a/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_geom.glsl b/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_geom.glsl index e26f419b8cd..c19598ea8ab 100644 --- a/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_geom.glsl +++ b/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_geom.glsl @@ -28,10 +28,18 @@ flat out vec4 finalColor; void emitLine(vec4 color) { gl_Position = ProjectionMatrix * MV_pos[0]; +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_set_clip_distance(gl_in[0].gl_ClipDistance); +#endif EmitVertex(); + gl_Position = ProjectionMatrix * MV_pos[1]; +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_set_clip_distance(gl_in[1].gl_ClipDistance); +#endif finalColor = color; EmitVertex(); + EndPrimitive(); } diff --git a/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl index 9de50246a40..3877c63d00a 100644 --- a/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_instance_edges_variying_color_vert.glsl @@ -37,7 +37,8 @@ void main() mat4 ModelViewMatrix = ViewMatrix * InstanceModelMatrix; - MV_pos = ModelViewMatrix * vec4(pos, 1.0); + vec4 pos_4d = vec4(pos, 1.0); + MV_pos = ModelViewMatrix * pos_4d; mat3 NormalMatrix = transpose(inverse(mat3(ModelViewMatrix))); @@ -60,4 +61,8 @@ void main() edgeClass = -1.0; // back-facing edge fCol = color; + +#ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_calc_clip_distance((InstanceModelMatrix * vec4(pos, 1.0)).xyz); +#endif } |