48 lines
911 B
Plaintext
48 lines
911 B
Plaintext
struct VertexShaderInput {
|
|
float2 aPos;
|
|
float2 aUV;
|
|
float4 aColor;
|
|
};
|
|
|
|
struct VertexShaderOutput {
|
|
float4 Pos : SV_POSITION;
|
|
float4 Color;
|
|
float2 UV;
|
|
};
|
|
|
|
[[vk::binding(0, 1)]]
|
|
cbuffer constants {
|
|
float2 uScale;
|
|
float2 uTranslate;
|
|
};
|
|
|
|
[shader("vertex")]
|
|
VertexShaderOutput main_vertex(float2 aPos, float2 aUV, float4 aColor)
|
|
{
|
|
VertexShaderOutput Out;
|
|
Out.Color = aColor;
|
|
Out.UV = aUV;
|
|
Out.Pos = float4(aPos * uScale + uTranslate, 0, 1);
|
|
Out.Pos.y *= -1.0f;
|
|
return Out;
|
|
}
|
|
|
|
struct PixelShaderOutput {
|
|
float4 color : SV_TARGET;
|
|
};
|
|
|
|
[[vk::binding(0, 2)]]
|
|
Sampler2DArray tile_textures;
|
|
|
|
[[vk::binding(0, 3)]]
|
|
cbuffer fragment_constants {
|
|
uint tile_index;
|
|
}
|
|
|
|
[shader("fragment")]
|
|
PixelShaderOutput main_fragment(float4 color, float2 uv) {
|
|
PixelShaderOutput Out;
|
|
Out.color = color * tile_textures.Sample(float3(uv, tile_index));
|
|
return Out;
|
|
}
|