power_play/res/shaders/triangle.hlsl

51 lines
1006 B
HLSL

#include "shaders/common.hlsl"
struct vs_input {
DECL(float4, pos);
DECL(float2, uv);
DECL(float4, tint_srgb);
};
struct ps_input {
DESV(float4, screen_pos, SV_POSITION);
DECL(float2, uv);
DECL(float4, tint_lin);
};
/* ========================== *
* Globals
* ========================== */
SamplerState G_sampler : register(s0);
Texture2D G_texture : register(t0);
cbuffer constants : register(b0)
{
float4x4 G_projection;
};
/* ========================== *
* Vertex shader
* ========================== */
ps_input vs_main(vs_input input)
{
ps_input output;
output.screen_pos = mul(G_projection, float4(input.pos.xy, 0.f, 1.f));
output.uv = input.uv;
output.tint_lin = linear_from_srgb(input.tint_srgb);
return output;
}
/* ========================== *
* Pixel shader
* ========================== */
float4 ps_main(ps_input input) : SV_TARGET
{
float4 color = G_texture.Sample(G_sampler, input.uv) * input.tint_lin;
return color;
}