bevy/crates/bevy_ui/src/render
ickshonpe 54733e82ae box-shadow clipping fix (#16790)
Instead of clipping the non-visable sections of box-shadows, the shadow
is scaled to fit into the remaining area after clipping because the
normalized coordinates that are meant to border the unclipped subsection
of the shadow are always set to `[Vec2::ZERO, Vec2::X, Vec2::ONE,
Vec2::Y]`,

Calculate the coordinates for the corners of the visible area.

Test app:

```rust
use bevy::color::palettes::css::RED;
use bevy::color::palettes::css::WHITE;
use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d);
    commands
        .spawn(Node {
            ..Default::default()
        })
        .with_children(|commands| {
            commands
                .spawn((
                    Node {
                        width: Val::Px(100.),
                        height: Val::Px(100.),
                        margin: UiRect {
                            left: Val::Px(100.),
                            top: Val::Px(300.),
                            ..Default::default()
                        },
                        overflow: Overflow::clip(),
                        ..Default::default()
                    },
                    BackgroundColor(WHITE.into()),
                ))
                .with_children(|commands| {
                    commands.spawn((
                        Node {
                            position_type: PositionType::Absolute,
                            left: Val::Px(50.),
                            top: Val::Px(50.),
                            width: Val::Px(100.),
                            height: Val::Px(100.),
                            ..Default::default()
                        },
                        BackgroundColor(RED.into()),
                        BoxShadow::from(ShadowStyle {
                            x_offset: Val::ZERO,
                            y_offset: Val::ZERO,
                            spread_radius: Val::Px(50.),
                            blur_radius: Val::Px(6.),
                            ..Default::default()
                        }),
                    ));
                });
        });
}
```

Main:
<img width="103" alt="bad_shadow"
src="https://github.com/user-attachments/assets/6f7ade0e-959f-4d18-92e8-903630eb8cd3"
/>

This PR:
<img width="98" alt="clipped_shadow"
src="https://github.com/user-attachments/assets/7f576c94-908c-4fe6-abaa-f18fefe05207"
/>
2025-01-03 19:26:37 +01:00
..
box_shadow.rs box-shadow clipping fix (#16790) 2025-01-03 19:26:37 +01:00
box_shadow.wgsl Remove the Globals binding from the box shadow shader (#16177) 2024-11-05 22:31:35 +01:00
mod.rs Only use physical coords internally in bevy_ui (#16375) 2024-11-22 21:23:59 +01:00
pipeline.rs Only use physical coords internally in bevy_ui (#16375) 2024-11-22 21:23:59 +01:00
render_pass.rs Only use physical coords internally in bevy_ui (#16375) 2024-11-22 21:23:59 +01:00
ui_material_pipeline.rs Only use physical coords internally in bevy_ui (#16375) 2024-11-22 21:23:59 +01:00
ui_material.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
ui_texture_slice_pipeline.rs UI slice bug (#16772) 2025-01-03 19:15:53 +01:00
ui_texture_slice.wgsl Fix some duplicate words in docs/comments (#15980) 2024-10-20 01:03:27 +00:00
ui_vertex_output.wgsl Include UI node size in the vertex inputs for UiMaterial. (#11722) 2024-02-06 16:15:09 +00:00
ui.wgsl Only use physical coords internally in bevy_ui (#16375) 2024-11-22 21:23:59 +01:00