From d712f1f83af881be536ec0d183b7d3025c172684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 23 Apr 2020 23:05:39 +0200 Subject: GPU: Add Polyline shader (wide line emulation) This new shader is able to emulate smooth wide lines drawing using a geometry shader. This shader needs viewportSize and lineWidth uniforms to be set. There is multiple variants to replace the usage of wide lines for most shaders. This patch only fix the gizmo_types files and the navigation gizmo. Other areas could be fixed afterward, I just limited the patch size. Fix T57570. Reviewed By: billreynish Differential Revision: https://developer.blender.org/D7487 --- .../gpu/shaders/gpu_shader_3D_polyline_frag.glsl | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 source/blender/gpu/shaders/gpu_shader_3D_polyline_frag.glsl (limited to 'source/blender/gpu/shaders/gpu_shader_3D_polyline_frag.glsl') diff --git a/source/blender/gpu/shaders/gpu_shader_3D_polyline_frag.glsl b/source/blender/gpu/shaders/gpu_shader_3D_polyline_frag.glsl new file mode 100644 index 00000000000..9c6b109d659 --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_3D_polyline_frag.glsl @@ -0,0 +1,24 @@ + +uniform float lineWidth; + +in vec4 finalColor; +noperspective in float smoothline; +#ifdef CLIP +in float clip; +#endif + +out vec4 fragColor; + +#define SMOOTH_WIDTH 1.0 + +void main() +{ +#ifdef CLIP + if (clip < 0.0) { + discard; + } +#endif + fragColor = finalColor; + fragColor.a *= clamp((lineWidth + SMOOTH_WIDTH) * 0.5 - abs(smoothline), 0.0, 1.0); + fragColor = blender_srgb_to_framebuffer_space(fragColor); +} -- cgit v1.2.3