deferred rendering with msaa

https://docs.nvidia.com/gameworks/content/gameworkslibrary/graphicssamples/d3d_samples/antialiaseddeferredrendering.htm

https://github.com/NVIDIAGameWorks/D3DSamples/tree/master/samples/DeferredShadingMSAA

 {

  float3 worldNormal = normalize(pixel.worldNorm);

  float viewDepth = pixel.viewDepth / 1000.0f;

   

  float3 diffuse = bTextured > 0 ? texDiffuse.Sample(textureSampler, float2(1, 1) - pixel.uv).rgb : DiffuseColor;

  float edge = coverage != 0xf;

   

  result.fragment1 = float4(worldNormal, viewDepth);

  result.fragment2 = float4(diffuse, edge);

  result.fragment3 = coverage;

}

coverage这个方法我倒是看懂了 缺点是 mesh的边缘都会被标记 实际上这里可能不需要超采样

这是另外一个方法判断 normal detph的连续性

    if(UseDiscontinuity == 1)
        {
            float4 gBuf1 = texGBufferMS1.Load(pixel.pos.xy, 0);
            float4 gBuf2 = texGBufferMS2.Load(pixel.pos.xy, 0);
            
            float3 normal = gBuf1.xyz;
            float depth = gBuf1.w;
            float3 albedo = gBuf2.xyz;
    

            [unroll]
            for(int i = 1; i < SAMPLE_COUNT; i++)
            {
                float4 nextGBuf1 = texGBufferMS1.Load(pixel.pos.xy, i);
                float4 nextGBuf2 = texGBufferMS2.Load(pixel.pos.xy, i);
                    
                float3 nextNormal = nextGBuf1.xyz;
                float nextDepth = nextGBuf1.w;
                float3 nextAlbedo = nextGBuf2.xyz;
    

                [branch]
                if(abs(depth - nextDepth) > 0.1f || abs(dot(abs(normal - nextNormal), float3(1, 1, 1))) > 0.1f || abs(dot(albedo - nextAlbedo, float3(1, 1, 1))) > 0.1f)
                {
                    clip(-0.5f);
                    return 0;
                }
            }
        }

一看就巨费 depth normal albedo大于某阈值就标记为complex pixle

用上述两种结果做光照

gbuffer 用msaa生成

但我总觉得我在哪还见过一篇 msaa+deferred的解决方案

msaa 的srv 用mstex.load(uv,sampleID) 放循环里

原文地址:https://www.cnblogs.com/minggoddess/p/10055349.html