struct VSOutput {
float4 position : SV_Position;
float2 ndc : TEXCOORD0;
};
[shader("vertex")]
VSOutput vsMain(uint vertexID: SV_VertexID) {
VSOutput output;
float2 uv = float2((vertexID << 1) & 2, vertexID & 2);
float2 pos = uv * 2.0 - 1.0;
output.position = float4(pos, 0.0, 1.0);
output.ndc = pos;
return output;
}
[shader("fragment")]
float4 fsMain(VSOutput input) : SV_Target {
float2 uv = input.ndc * 0.5 + 0.5;
float3 grad = float3(uv.x, uv.y, 0.0);
float2 d = abs(input.ndc);
float cross = (min(d.x, d.y) < 0.01) ? 1.0 : 0.0;
float3 color = lerp(grad, float3(1.0, 1.0, 1.0), cross);
return float4(color, 1.0);
}