49 lines
933 B
Plaintext
49 lines
933 B
Plaintext
struct Fragment {
|
|
float4 color : SV_Target;
|
|
}
|
|
|
|
struct VertexIn {
|
|
[[vk::layout(0)]] float2 pos;
|
|
[[vk::layout(1)]] float2 uv;
|
|
[[vk::layout(2)]] float4 color;
|
|
}
|
|
struct VertexOut {
|
|
[[vk::layout(0)]] float4 color;
|
|
[[vk::layout(1)]] float2 uv;
|
|
float4 position : SV_Position;
|
|
}
|
|
|
|
struct PushConstant {
|
|
float2 screen_size;
|
|
}
|
|
|
|
[[vk::push_constant]]
|
|
ConstantBuffer<PushConstant> push_constant;
|
|
|
|
[shader("vertex")]
|
|
VertexOut vertex(VertexIn vertex) {
|
|
VertexOut output;
|
|
|
|
output.position = float4(
|
|
2.0 * vertex.pos.x / push_constant.screen_size.x - 1.0,
|
|
2.0 * vertex.pos.y / push_constant.screen_size.y - 1.0,
|
|
0.0,
|
|
1.0,
|
|
);
|
|
output.color = vertex.color;
|
|
output.uv = vertex.uv;
|
|
|
|
return output;
|
|
}
|
|
|
|
[[vk::binding(0)]]
|
|
Sampler2D texture;
|
|
|
|
[shader("fragment")]
|
|
Fragment fragment(VertexOut input) {
|
|
Fragment output;
|
|
|
|
output.color = input.color * texture.Sample(input.uv);
|
|
return output;
|
|
}
|