mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-24 20:51:10 +00:00
gpu: Improve conic gradient rendering
1. Compute the fwidth() twice with offset offsets That way, we avoid glitches at the boundary between 0.0 and 1.0, because by offsetting it by 0.5, that boundary goes away. Then we take the min() of both which gives us the one we care about. 2. Set the gradient to repeating By doing that, we don't get values at the 0.0/1.0 boundary clamped, but things smoothly transition. This smoothes the line at that boundary and makes it look just like every other line.
This commit is contained in:
parent
88618952c5
commit
d1d1af1a62
@ -187,10 +187,12 @@ conic_gradient_pattern (inout uint reader,
|
||||
/* scaling modifies angles, so be sure to use right coordinate system */
|
||||
pos = pos / push.scale - center;
|
||||
float offset = atan (pos.y, pos.x);
|
||||
offset = fract (degrees (offset + angle) / 360.0);
|
||||
float d_offset = 0.5 * fwidth (offset);
|
||||
offset = degrees (offset + angle) / 360.0;
|
||||
float overflow = fract (offset + 0.5);
|
||||
offset = fract (offset);
|
||||
float d_offset = max (0.00001, 0.5 * min (fwidth (offset), fwidth (overflow)));
|
||||
|
||||
return gradient_get_color (gradient, offset - d_offset, offset + d_offset);
|
||||
return gradient_get_color_repeating (gradient, offset - d_offset, offset + d_offset);
|
||||
}
|
||||
|
||||
vec4
|
||||
|
Loading…
Reference in New Issue
Block a user