PDA

View Full Version : MSAA in deferred shading questions



TheKaiser
06-16-2014, 02:36 AM
I'm trying to tackle MSAA in deferred shading.

Here' my current deferred renderering pipeline:


1. Geometry stage - Render geometry to textures (position/normals/diffuse)
2. Shading stage - all output is rendered & blended into a "final texture"
2.1 Render ambient light
2.2 Render directional lights and shadows
2.3 Render point lights and shadows
3. BlitFramebuffer() on the final texture
4. Swapbuffers and repeat 1.

In 2.1, 2.2 and 2.3 I need to read gbuffer textures (position/normals/diffuse) to do the lighting and shadowing.

My question is now, how do I most effectively accomplish MSAA (or any other form of good AA)? Do I have to read a number of samples in all the 3 shading passes (2.1, 2.2 and 2.3: sounds expensive!) or what?

Dark Photon
06-16-2014, 05:31 AM
My question is now, how do I most effectively accomplish MSAA (or any other form of good AA)? Do I have to read a number of samples in all the 3 shading passes (2.1, 2.2 and 2.3: sounds expensive!) or what?

Yes. Though it's not as expensive as you'd think it'd be. Years ago, Killzone did this IIRC, running shaders per-pixel, reading all the subsamples (2X I think), and writing out to a 1X lighting buffer. I've done it with 4X -> 1X and was really shocked at how fast it is on a high-end GPU. This is easy to try, so I would just do it and see what you find on your hardware.

Then there's the whole issue of how to maximize efficiency with MSAA deferred. I'd highly recommend Lauritzen's 2010 SIGGRAPH talk on Deferred Shading (Deferred Rendering for Current and Future Rendering Pipelines). Get rid of all the state changes between light sources, look toward tile-based deferred, and then pushing the entire lighting pass (light source culling, binning, and rendering) onto the GPU.

TheKaiser
06-16-2014, 06:44 AM
I'm kinda torn between going either MSAA or FXAA (or both combined? at the same time? if that works) approach to my deferred shading. Any recommendations?

For FXAA I know theres a shader lying around one can plug-and-play almost once all lighting is done.

For MSAA, are you supposed to make the gbuffer render targets MSAA x2/x4 and then in the lighting shaders texelFetch() based on the number of samples?

Is one superior to the other?

EDIT: I'd like to add I'm going for OpenGL 4.2 atleast

Dark Photon
06-17-2014, 04:38 AM
For FXAA I know theres a shader lying around one can plug-and-play almost once all lighting is done.

For MSAA, are you supposed to make the gbuffer render targets MSAA x2/x4 and then in the lighting shaders texelFetch() based on the number of samples?

Is one superior to the other?

Superior how? As with all things, it depends on your requirements. Is edge AA quality or GPU mem consumption/bandwidth more important to you for instance?

Osbios
06-17-2014, 11:34 AM
Seeing it in game like Crysis3, I actually like 2xMSAA with SMAA. Its called SMAA T2.
I also like the temporal AA that tesseract (http://tesseract.gg/) uses. (its free oss, so just test it)