Skip to content

Commit

Permalink
Changed selectCorner to take a vec2 instead of separate x and y f32s.
Browse files Browse the repository at this point in the history
  • Loading branch information
ickshonpe committed Sep 20, 2024
1 parent 034e2e2 commit c31f4d4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/bevy_ui/src/render/box_shadow.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ fn erf(p: vec2<f32>) -> vec2<f32> {
return s - s / (result * result);
}

// returns the closest corner radius based on the sign of x and y
fn selectCorner(x: f32, y: f32, c: vec4<f32>) -> f32 {
return mix(mix(c.x, c.y, step(0., x)), mix(c.w, c.z, step(0., x)), step(0., y));
// returns the closest corner radius based on the signs of the components of p
fn selectCorner(p: vec2<f32>, c: vec4<f32>) -> f32 {
return mix(mix(c.x, c.y, step(0., p.x)), mix(c.w, c.z, step(0., p.x)), step(0., p.y));
}

fn horizontalRoundedBoxShadow(x: f32, y: f32, blur: f32, corner: f32, half_size: vec2<f32>) -> f32 {
Expand Down Expand Up @@ -59,7 +59,7 @@ fn roundedBoxShadow(
var y = start + step * 0.5;
var value: f32 = 0.0;
for (var i = 0; i < SAMPLES; i++) {
let corner = selectCorner(p.x, p.y, corners);
let corner = selectCorner(p, corners);
value += horizontalRoundedBoxShadow(p.x, p.y - y, blur, corner, half_size) * gaussian(y, blur) * step;
y += step;
}
Expand Down

0 comments on commit c31f4d4

Please sign in to comment.