Reputation: 105
I am creating my Colour and Depth textures using a sample description of count 8. When rendering geometry the MSAA appears to be working nicely.
However, in my sprite based shaders, where I render square sprites as 2 triangles using a geometry shader, and clip pixels using the alpha of the sprite texture in the pixel shader, I am not getting MSAA.
e.g, my pixel shader looks something like this
float4 PSMain(in GSOutput input) : SV_TARGET
{
float4 tex = Texture.Sample(TextureSampler, input.Tex);
if (tex.w < 1)
{
discard;
}
return float4(tex.xyz, tex.w);
}
Is it possible to achieve MSAA here? am I missing something?
Upvotes: 1
Views: 44
Reputation: 1924
This is not a specialty of mine, but I believe MSAA does not work with alpha testing (the technique you're using here) - in fact, the Wikipedia page for MSAA calls out this exact problem. In essence, your multisampled pixels fail the alpha test and get discarded, preventing any of them from actually showing up in the first place.
You'll likely need to just remove the alpha test completely, or create a coverage mask slightly larger than the object and reject any pixels outside of the mask. So long as your mask is larger than any possible multisampled pixel, there's no risk of reoccurrence. Take that second option with a grain of salt, however - I'm absolutely not an expert in advanced rendering techniques.
Upvotes: 1