2021-10-20 21:44:06 +00:00
|
|
|
/// Shader used for drawing solid color fills.
|
|
|
|
|
|
|
|
struct VertexOutput {
|
2022-07-02 12:18:30 +00:00
|
|
|
@builtin(position) position: vec4<f32>,
|
|
|
|
@location(0) color: vec4<f32>,
|
2021-10-20 21:44:06 +00:00
|
|
|
};
|
|
|
|
|
2022-07-02 12:18:30 +00:00
|
|
|
@vertex
|
2021-10-26 04:36:19 +00:00
|
|
|
fn main_vertex(in: VertexInput) -> VertexOutput {
|
2022-05-12 18:46:52 +00:00
|
|
|
let pos = globals.view_matrix * transforms.world_matrix * vec4<f32>(in.position.x, in.position.y, 0.0, 1.0);
|
|
|
|
let color = in.color * transforms.mult_color + transforms.add_color;
|
|
|
|
let alpha = clamp(color.a, 0.0, 1.0);
|
|
|
|
return VertexOutput(pos, vec4<f32>(color.rgb * alpha, alpha));
|
2021-10-20 21:44:06 +00:00
|
|
|
}
|
|
|
|
|
2022-07-02 12:18:30 +00:00
|
|
|
@fragment
|
|
|
|
fn main_fragment(in: VertexOutput) -> @location(0) vec4<f32> {
|
2022-05-12 18:46:52 +00:00
|
|
|
return in.color;
|
2021-10-20 21:44:06 +00:00
|
|
|
}
|