Repository: iced-rs/iced (language: rust)

Issue:
Custom Quad's drop shadow broken
### Is there an existing issue for this?

- [X] I have searched the existing issues.

### Is this issue related to iced?

- [X] My hardware is compatible and my graphics drivers are up-to-date.

### What happened?

Drop shadow looks bad.
<img width="691" alt="Screenshot 2024-02-25 at 11 56 59" src="https://github.com/iced-rs/iced/assets/31200/15d69e0f-10d0-49b5-9824-9b060b1bcb47">


### What is the expected behavior?

The drop shadow should look like the quad.

### Version

master

### Operating System

macOS

### Do you have any log output?

_No response_


Discussion / hints:

Fix patch:
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs
index 8c8781e345..0c913c02f5 100644
--- a/tiny_skia/src/backend.rs
+++ b/tiny_skia/src/backend.rs
@@ -233,7 +233,8 @@ impl Backend {
                                         ),
                                         size,
                                         &radii,
-                                    );
+                                    )
+                                    .max(0.0);
                                     let shadow_alpha = 1.0
                                         - smoothstep(
                                             -shadow.blur_radius * scale_factor,
diff --git a/wgpu/src/shader/quad/solid.wgsl b/wgpu/src/shader/quad/solid.wgsl
index 1274f81481..d908afbcb0 100644
--- a/wgpu/src/shader/quad/solid.wgsl
+++ b/wgpu/src/shader/quad/solid.wgsl
@@ -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);


Test patch: