49 lines
1.0 KiB
Plaintext
49 lines
1.0 KiB
Plaintext
struct VSInput {
|
|
float2 pos;
|
|
float2 scale;
|
|
float2 uv;
|
|
float4 color;
|
|
float alpha;
|
|
uint32_t textureID;
|
|
};
|
|
|
|
struct VSOutput {
|
|
float4 pos : SV_POSITION;
|
|
float2 uv;
|
|
float4 color;
|
|
float alpha;
|
|
uint32_t tex_id;
|
|
};
|
|
|
|
static const float2 square[6] = {
|
|
float2(-0.5, -0.5), // Top-left
|
|
float2(-0.5, 0.5), // Bottom-left
|
|
float2( 0.5, -0.5), // Top-right
|
|
|
|
float2( 0.5, -0.5), // Top-right
|
|
float2(-0.5, 0.5), // Bottom-left
|
|
float2( 0.5, 0.5) // Bottom-right
|
|
};
|
|
|
|
[shader ("vertex")]
|
|
VSOutput main(VSInput input, uint vertex_index : SV_VertexID) {
|
|
VSOutput output;
|
|
|
|
float2 vertex_pos = square[vertex_index % 6];
|
|
float2 final_pos = (vertex_pos * input.scale) + input.pos;
|
|
|
|
output.pos = float4(final_pos, 0.0, 1.0);
|
|
output.uv = input.uv;
|
|
output.color = input.color;
|
|
output.alpha = input.alpha;
|
|
output.tex_id = input.textureID;
|
|
|
|
return output;
|
|
}
|
|
|
|
[shader("fragment")]
|
|
float4 main(VSOutput input) {
|
|
|
|
return float4(input.color.rgb, input.alpha);
|
|
}
|