[Bf-blender-cvs] [187e217b5a7] master: UI: Fix widget emboss: Also fade on the right side

Leon Leno noreply at git.blender.org
Tue Jun 22 22:23:20 CEST 2021


Commit: 187e217b5a72ec7a1e66ee3e1dc2a7910a5feea9
Author: Leon Leno
Date:   Tue Jun 22 15:21:53 2021 -0500
Branches: master
https://developer.blender.org/rB187e217b5a72ec7a1e66ee3e1dc2a7910a5feea9

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

===================================================================

M	source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl

===================================================================

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;



More information about the Bf-blender-cvs mailing list