MSAA resolve of normals

Started by
7 comments, last by Alundra 1 week, 6 days ago

Hi everybody!

Rendering opaque geometries using forward shading to HDR render target with MSAA and outputing in the same pass normals in view space in a second target, you have then to resolve to use them. Resolving the lighting result of the first render target is not a problem, you can simply use “ResolveSubresource”.

How to deal correctly with the normals which is multi-sampled?
Does it need a special shader? What is the correct processing by pixel?

The main goal is to apply SSAO after the opaque rendering pass using depth + normal.
The issue is depth and normal are multi-sampled and needs to be resolved.

Thanks for the help!

Advertisement

It doesn't seem correct to me to apply SSAO after shading the opaque geometry, since it would affect both direct and indirect lighting. SSAO should only affect the ambient term of your lighting, which means the ambient occlusion factor needs to be known when you are shading. This means you should consider a deferred renderer, or alternatively do a Z pre-pass so that you can calculate SSAO before the main pass.

I know nothing about MSAA, but for SSAO it might be good enough and faster to calculate normals from depth, if that helps.
Agree about the correctness concerns. But depends on content, and since AO is not based on physics, arguments about correctness stand on short legs a bit. ; )

@Alundra You have to apply SSAO before MSAA resolve, otherwise it will break your multisampling ending in jaggies without getting the required results of MSAA.

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

@aressera It's common to apply the SSAO on top of the lighting result like Unreal and Doom Eternal because SSAO is already a fake so it's used more as an artistic effect.

@vilem otte Yes it was what I tried to avoid… to output the multi sampled SSAO…

The HBAO paper says: “If MultiSample AntiAliasing (MSAA) is enabled, resolve the MSAA colors using ResolveSubresource and resolve the MSAA depths and normals using a fullscreen shader pass which outputs an arbitrary sample per pixel.”

Alundra said:
It's common to apply the SSAO on top of the lighting result like Unreal and Doom Eternal because SSAO is already a fake so it's used more as an artistic effect.

I wouldn't be so sure about that. Imagine you shine a light in a corner. If you apply SSAO after all lighting, then even though the corner is hit by direct light it will be darkened, which is not realistic. I doubt Unreal would be getting things that wrong.

I looked up the idTech6 presentation for Doom from 2016 SIGGRAPH, here is the relevant slide (last one in PDF):

As you can see, they do AO in the final composite pass, which is also where they handle ambient lighting (environment probes). Therefore, they can apply SSAO to just the ambient light in a way that is physically correct, and composite it with the forward direct pass, since the lighting is additive. What they aren't doing is darkening the direct lighting result from the forward opaque pass. That's just wrong.

Even if you do a GBuffer first with color and normal, you end to have multi-sampled GBuffer so it ends to the same issue then, how to deal with this MSAA GBuffer during lighting and then for SSAO. There is a resolve issue.

Advertisement