Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tiny_skia/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ impl Backend {
),
size,
&radii,
);
)
.max(0.0);
let shadow_alpha = 1.0
- smoothstep(
-shadow.blur_radius * scale_factor,
Expand Down
12 changes: 9 additions & 3 deletions wgpu/src/shader/quad/solid.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down