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?
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?
Share Improve this question asked Jan 19 at 17:05 jessejbweldjessejbweld 1056 bronze badges 1- I guess you expect multisampling to work not only for pixels belonging to triangle edges but to pixels belonging to inner areas of triangles as well. – user7860670 Commented Jan 26 at 18:08
1 Answer
Reset to default 1This 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.