2025-03-18 10:39:01 +01:00
|
|
|
|
2025-03-19 16:27:55 +01:00
|
|
|
#[set(everything)]
|
2025-03-18 10:39:01 +01:00
|
|
|
const constants: {
|
2025-04-20 23:29:05 +02:00
|
|
|
pos: float4; // xywh
|
|
|
|
|
col: float4;
|
2025-03-18 10:39:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct vert_in {
|
2025-04-20 23:29:05 +02:00
|
|
|
pos: float2;
|
2025-03-18 10:39:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct vert_out {
|
|
|
|
|
pos: float4;
|
|
|
|
|
col: float4;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-24 22:19:44 +02:00
|
|
|
fun draw_rect_vert(input: vert_in): vert_out {
|
2025-03-18 10:39:01 +01:00
|
|
|
var output: vert_out;
|
2025-05-16 19:05:00 +02:00
|
|
|
|
|
|
|
|
var cpos: float4 = constants.pos;
|
|
|
|
|
|
2025-04-20 23:29:05 +02:00
|
|
|
output.pos = float4(input.pos, 0.0, 1.0);
|
2025-05-16 19:05:00 +02:00
|
|
|
output.pos.xy = output.pos.xy * cpos.zw + cpos.xy;
|
2025-04-20 23:29:05 +02:00
|
|
|
output.pos.xy = output.pos.xy * 2.0 - 1.0;
|
|
|
|
|
output.pos.y = -output.pos.y;
|
|
|
|
|
output.col = constants.col;
|
2025-03-18 10:39:01 +01:00
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-24 22:19:44 +02:00
|
|
|
fun draw_rect_frag(input: vert_out): float4 {
|
2025-03-18 10:39:01 +01:00
|
|
|
return input.col;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[pipe]
|
|
|
|
|
struct pipe {
|
2025-04-24 22:19:44 +02:00
|
|
|
vertex = draw_rect_vert;
|
|
|
|
|
fragment = draw_rect_frag;
|
2025-03-18 10:39:01 +01:00
|
|
|
}
|