From 187e217b5a72ec7a1e66ee3e1dc2a7910a5feea9 Mon Sep 17 00:00:00 2001 From: Leon Leno Date: Tue, 22 Jun 2021 15:21:53 -0500 Subject: UI: Fix widget emboss: Also fade on the right side Currently the emboss is only fading on left side of the widget, resulting in the emboss extending vertically on the right side and ending abruptly. This patch fixes this by also fading the emboss on the right side and making it symmetric. Differential Revision: https://developer.blender.org/D10810 --- source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl index 21c7f79a57c..6dd0201535d 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl @@ -36,6 +36,9 @@ vec3 compute_masks(vec2 uv) corner_rad = right_half ? outRoundCorners.y : outRoundCorners.x; } + /* Fade emboss at the border. */ + float emboss_size = upper_half ? 0.0 : min(1.0, uv_sdf.x / (corner_rad * ratio)); + /* Signed distance field from the corner (in pixel). * inner_sdf is sharp and outer_sdf is rounded. */ uv_sdf -= corner_rad; @@ -43,9 +46,6 @@ vec3 compute_masks(vec2 uv) float outer_sdf = -length(min(uv_sdf, 0.0)); float sdf = inner_sdf + outer_sdf + corner_rad; - /* Fade emboss at the border. */ - float emboss_size = clamp((upper_half) ? 0.0 : (uv.x / corner_rad), 0.0, 1.0); - /* Clamp line width to be at least 1px wide. This can happen if the projection matrix * has been scaled (i.e: Node editor)... */ float line_width = (lineWidth > 0.0) ? max(fwidth(uv.y), lineWidth) : 0.0; -- cgit v1.2.3