Replace blend with mix equivalent in quad shaders

This commit is contained in:
Héctor Ramón Jiménez 2025-05-12 18:11:51 +02:00
parent 9ac4c9f13d
commit df37d6f9bc
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 3 additions and 7 deletions

View file

@ -9,10 +9,6 @@ fn premultiply(color: vec4<f32>) -> vec4<f32> {
return vec4(color.xyz * color.a, color.a);
}
fn blend(over: vec4<f32>, under: vec4<f32>, alpha: f32) -> vec4<f32> {
return over * alpha + under * (1.0 - alpha);
}
fn distance_alg(
frag_coord: vec2<f32>,
position: vec2<f32>,

View file

@ -179,7 +179,7 @@ fn gradient_fs_main(input: GradientVertexOutput) -> @location(0) vec4<f32> {
internal_distance
);
mixed_color = blend(input.border_color, mixed_color, border_mix);
mixed_color = mix(mixed_color, input.border_color, border_mix);
}
var dist: f32 = distance_alg(

View file

@ -97,7 +97,7 @@ fn solid_fs_main(
internal_distance
);
mixed_color = blend(input.border_color, input.color, border_mix);
mixed_color = mix(input.color, input.border_color, border_mix);
}
var dist: f32 = distance_alg(
@ -125,7 +125,7 @@ fn solid_fs_main(
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);
return blend(input.shadow_color, quad_color, (1.0 - radius_alpha) * shadow_alpha);
return mix(quad_color, input.shadow_color, (1.0 - radius_alpha) * shadow_alpha);
} else {
return quad_color;
}