I'd like the make an HLSL pixel shader that can round the corners of a quad. I attempted to port this GLSL example the following way:
cbuffer CBuf : register(b0)
{
float4 color;
float2 dimensions;
float radius;
float na;
};
struct VSOut
{
float4 pos : SV_POSITION;
float2 uv : UV;
uint viewId : SV_RenderTargetArrayIndex;
};
float4 main(VSOut input) : SV_TARGET
{
float2 coords = input.uv * dimensions;
if
(
length(coords) < radius ||
length(coords - float2(0, dimensions.y)) < radius ||
length(coords - float2(dimensions.x, 0)) < radius ||
length(coords - dimensions) < radius
)
{
discard;
}
return color;
}
What I end up with is this: But I'm looking for more of a rounded rectangle shape.