Merge pull request #2354 from Koranir/custom-shadow-fix
Fix quad shadows
This commit is contained in:
commit
5071e3d231
2 changed files with 11 additions and 4 deletions
|
|
@ -233,7 +233,8 @@ impl Backend {
|
|||
),
|
||||
size,
|
||||
&radii,
|
||||
);
|
||||
)
|
||||
.max(0.0);
|
||||
let shadow_alpha = 1.0
|
||||
- smoothstep(
|
||||
-shadow.blur_radius * scale_factor,
|
||||
|
|
|
|||
|
|
@ -107,13 +107,19 @@ fn solid_fs_main(
|
|||
let quad_color = vec4<f32>(mixed_color.x, mixed_color.y, mixed_color.z, mixed_color.w * radius_alpha);
|
||||
|
||||
if input.shadow_color.a > 0.0 {
|
||||
let shadow_distance = rounded_box_sdf(input.position.xy - input.pos - input.shadow_offset - (input.scale / 2.0), input.scale / 2.0, border_radius);
|
||||
let shadow_radius = select_border_radius(
|
||||
input.border_radius,
|
||||
input.position.xy - input.shadow_offset,
|
||||
(input.pos + input.scale * 0.5).xy
|
||||
);
|
||||
let shadow_distance = max(rounded_box_sdf(input.position.xy - input.pos - input.shadow_offset - (input.scale / 2.0), input.scale / 2.0, shadow_radius), 0.);
|
||||
|
||||
let shadow_alpha = 1.0 - smoothstep(-input.shadow_blur_radius, input.shadow_blur_radius, shadow_distance);
|
||||
let shadow_color = input.shadow_color;
|
||||
let base_color = select(
|
||||
let base_color = mix(
|
||||
vec4<f32>(shadow_color.x, shadow_color.y, shadow_color.z, 0.0),
|
||||
quad_color,
|
||||
quad_color.a > 0.0
|
||||
quad_color.a
|
||||
);
|
||||
|
||||
return mix(base_color, shadow_color, (1.0 - radius_alpha) * shadow_alpha);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue