最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

directx - DirectX11 discardclip pixel MSAA - Stack Overflow

programmeradmin2浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 1

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.

发布评论

评论列表(0)

  1. 暂无评论