47 lines
1.0 KiB
HLSL
47 lines
1.0 KiB
HLSL
/*
|
|
* TODO:
|
|
* * maybe rename this to 'sprite.hlsl' (draw_rect and stuff would become draw_sprite)
|
|
* that way UI & text can have a separate shader (IE: draw_ui_rect, draw_ui_text, etc...)
|
|
*
|
|
* for tiles - separate shader. maybe upload all tile data in constant buffer, and drawing
|
|
* tiles can just be one giant quad (that the fragment shader indexes into)
|
|
*/
|
|
|
|
struct {
|
|
SamplerState sampler0;
|
|
Texture2D texture0;
|
|
} globals;
|
|
|
|
struct vs_input {
|
|
float4 pos : POSITION;
|
|
float2 uv : TEXCOORD;
|
|
float4 col : COLOR;
|
|
};
|
|
|
|
struct ps_input {
|
|
float4 pos : SV_POSITION;
|
|
float2 uv : TEXCOORD;
|
|
float4 col : COLOR;
|
|
};
|
|
|
|
cbuffer vs_constants : register(b0)
|
|
{
|
|
float4x4 projection;
|
|
};
|
|
|
|
ps_input vs_main(vs_input input)
|
|
{
|
|
ps_input output;
|
|
|
|
output.pos = mul(projection, float4(input.pos.xy, 0.f, 1.f));
|
|
output.uv = input.uv;
|
|
output.col = input.col;
|
|
|
|
return output;
|
|
}
|
|
|
|
float4 ps_main(ps_input input) : SV_TARGET
|
|
{
|
|
return globals.texture0.Sample(globals.sampler0, input.uv) * input.col;
|
|
}
|