2021-10-20 21:44:06 +00:00
|
|
|
/// Shader used for drawing solid color fills.
|
|
|
|
|
2024-05-14 10:50:37 +00:00
|
|
|
// NOTE: The `common.wgsl` source is prepended to this before compilation.
|
2023-01-06 22:17:42 +00:00
|
|
|
|
2023-01-30 20:45:44 +00:00
|
|
|
struct VertexInput {
|
|
|
|
@location(0) position: vec2<f32>,
|
|
|
|
@location(1) color: vec4<f32>,
|
|
|
|
};
|
|
|
|
|
2021-10-20 21:44:06 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2024-05-14 10:50:37 +00:00
|
|
|
@group(1) @binding(0) var<uniform> transforms: common__Transforms;
|
2023-01-06 22:17:42 +00:00
|
|
|
|
2022-07-02 12:18:30 +00:00
|
|
|
@vertex
|
2023-01-30 20:45:44 +00:00
|
|
|
fn main_vertex(in: VertexInput) -> VertexOutput {
|
2024-05-14 10:50:37 +00:00
|
|
|
let pos = common__globals.view_matrix * transforms.world_matrix * vec4<f32>(in.position.x, in.position.y, 0.0, 1.0);
|
2024-01-23 21:06:44 +00:00
|
|
|
let color = saturate(in.color * transforms.mult_color + transforms.add_color);
|
2023-04-02 05:30:07 +00:00
|
|
|
return VertexOutput(pos, vec4<f32>(color.rgb * color.a, color.a));
|
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> {
|
2023-04-02 05:30:07 +00:00
|
|
|
return in.color;
|
2021-10-20 21:44:06 +00:00
|
|
|
}
|